Fixes issue 24577: Direct link works properly in grids with implicit filters
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 29 Dec 2014 18:34:58 +0100
changeset 25719 675fc7b4fbac
parent 25718 ee94d9308674
child 25720 b614afc46817
Fixes issue 24577: Direct link works properly in grids with implicit filters

When a view was open by pasting a URL link (either in the address bar or in the quick view), the implicit filter of the header grid was always applied, even if the filters had been clea
red before obtaining the link.

This has been fixed by storing in the URL info about the grid filter clause state when the link is obtained. Then, when opening a view from that link, if there were no filter clauses wh
en the link was obtained, the grid will be initialized without them.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Mon Dec 29 12:22:58 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Mon Dec 29 18:34:58 2014 +0100
@@ -469,6 +469,13 @@
       };
     }
 
+    if (this.view.isRootView && this.view.standardWindow.emptyFilterClause) {
+      // this.view.standardWindow.emptyFilterClause will be true if the grid is being built based on
+      // an URL that was obtained from a grid that either did not have originally a filterClause or
+      // whose filters had been cleared
+      delete this.filterClause;
+    }
+
     var ret = this.Super('initWidget', arguments);
 
     // only show summary rows if there are summary functions
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Mon Dec 29 12:22:58 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Mon Dec 29 18:34:58 2014 +0100
@@ -747,6 +747,11 @@
           })) + '&';
         }
       }
+      if (!this.viewGrid.filterClause) {
+        // if the grid does not currently have a filterClause (i.e. because the filters have been cleared), make it explicit in the URL
+        // this way the filter clause can be removed when building a grid based on this URL (see issue https://issues.openbravo.com/view.php?id=24577)
+        url = url + '&emptyFilterClause=true';
+      }
     }
 
     return url;
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Mon Dec 29 12:22:58 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js	Mon Dec 29 18:34:58 2014 +0100
@@ -384,6 +384,10 @@
       }
     }
 
+    if (urlParams.emptyFilterClause) {
+      view.emptyFilterClause = urlParams.emptyFilterClause;
+    }
+
     if (urlParams.replaceDefaultFilter) {
       view.replaceDefaultFilter = urlParams.replaceDefaultFilter;
     }