details:   https://code.openbravo.com/erp/devel/pi/rev/5051c9b57bb4
changeset: 24228:5051c9b57bb4
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Aug 11 14:02:52 2014 +0200
summary:   Fixes issue 27303: direct link filtered by FK column doesn't work

The problem was that the identifier of the foreign key being filtered now is 
not stored in the criteria itself, because it is filtered using the id. To fix 
this, the chache with
the map of fk-id, fk-identifiers of the filtered foreign keys is stored in the 
url, and then applied when the grid filter editor is available.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
      |  12 +++++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
  |   9 ++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
 |   3 ++
 3 files changed, 22 insertions(+), 2 deletions(-)

diffs (75 lines):

diff -r 075ca846cedf -r 5051c9b57bb4 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Mon Aug 11 11:43:25 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Mon Aug 11 14:02:52 2014 +0200
@@ -1249,7 +1249,7 @@
   },
 
   setView: function (view) {
-    var dataPageSizeaux, length, i, crit, groupByMaxRecords;
+    var dataPageSizeaux, length, i, crit, groupByMaxRecords, fkCache;
 
     this.view = view;
 
@@ -1274,6 +1274,10 @@
     if (this.view.tabId === this.view.standardWindow.additionalCriteriaTabId 
&& this.view.standardWindow.additionalCriteria) {
       crit = 
isc.JSON.decode(unescape(this.view.standardWindow.additionalCriteria));
       this.setCriteria(crit);
+      if (this.view.standardWindow.fkCache) {
+        this.fkCache = 
isc.JSON.decode(unescape(this.view.standardWindow.fkCache));
+        // cannot apply the fkCache yet because the grid might not have a 
filter editor yet
+      }
       delete this.view.standardWindow.additionalCriteria;
     }
     // if there is no autoexpand field then just divide the space
@@ -1542,6 +1546,12 @@
 
     this.resetEmptyMessage();
     this.view.updateTabTitle();
+    // apply the fk cache to ensure the identifiers of the filtered foreign 
keys are shown
+    if (this.fkCache) {
+      this.loadFilterAuxiliaryCache(this.fkCache);
+      // delete it to avoid loading the cache more than once
+      delete this.fkCache;
+    }
 
     /*
      * In case the url contains advanced criteria, the initial criteria 
contains the criteria to be applied. So it should not be deleted.
diff -r 075ca846cedf -r 5051c9b57bb4 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Aug 11 11:43:25 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Aug 11 14:02:52 2014 +0200
@@ -702,7 +702,7 @@
 
   getDirectLinkUrl: function () {
     var url = window.location.href,
-        crit;
+        crit, fkCache;
     var qIndex = url.indexOf('?');
     var dIndex = url.indexOf('#');
     var index = -1;
@@ -735,6 +735,13 @@
           prettyPrint: false,
           dateFormat: 'dateConstructor'
         }));
+        fkCache = this.viewGrid.getFKFilterAuxiliaryCache(crit);
+        if (isc.isA.Array(fkCache) && fkCache.length > 0) {
+          url = url + '&fkCache=' + escape(isc.JSON.encode(fkCache, {
+            prettyPrint: false,
+            dateFormat: 'dateConstructor'
+          })) + '&';
+        }
       }
     }
 
diff -r 075ca846cedf -r 5051c9b57bb4 
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/utilities/ob-utilities.js
        Mon Aug 11 11:43:25 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
        Mon Aug 11 14:02:52 2014 +0200
@@ -379,6 +379,9 @@
     if (urlParams.criteria) {
       view.additionalCriteriaTabId = data.tabId;
       view.additionalCriteria = urlParams.criteria;
+      if (urlParams.fkCache) {
+        view.fkCache = urlParams.fkCache;
+      }
     }
 
     if (urlParams.replaceDefaultFilter) {

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to