Url based filterclause for direct linking to grid content, contributed by TDS, Mallikarjun M, Sreedhar Sirigiri, solved jslint warnings
authorMartin Taal <martin.taal@openbravo.com>
Tue, 17 May 2011 21:44:25 +0200
changeset 12209 1d0fdd55e10a
parent 12208 bb06abdd13c1
child 12210 e49590067220
child 12215 69a0581510c6
Url based filterclause for direct linking to grid content, contributed by TDS, Mallikarjun M, Sreedhar Sirigiri, solved jslint warnings
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Tue May 17 21:08:54 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Tue May 17 21:44:25 2011 +0200
@@ -267,6 +267,9 @@
   recordId = OB.Utilities.removeFragment(recordId);
   command = OB.Utilities.removeFragment(command);
   
+  var urlParams = OB.Utilities.getUrlParameters();
+  
+  //added to have the additional filter clause and tabid. Mallikarjun M
   var callback = function(response, data, request){
     command = command || 'DEFAULT';
     var view = {
@@ -284,6 +287,19 @@
     if (recordId) {
       view.targetRecordId = recordId;
     }
+    
+    //// Begins-added to have the additional filter clause and tabid..Mallikarjun M
+    //URL example:http://localhost:8080/openbravo/?tabId=186&filterClause=e.businessPartner.searchKey%3D%27mcgiver%27&replaceDefaultFilter=true&
+    if (urlParams.filterClause) {
+      view.additionalFilterTabId = data.tabId;
+        view.additionalFilterClause = urlParams.filterClause;
+    }
+     
+    if (urlParams.replaceDefaultFilter) {
+       view.replaceDefaultFilter = urlParams.replaceDefaultFilter;
+    }
+    ////Ends..
+    
     OB.Layout.ViewManager.openView(view.viewId, view);
   };
   
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Tue May 17 21:08:54 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Tue May 17 21:44:25 2011 +0200
@@ -345,6 +345,19 @@
       this.getField(this.view.parentProperty).canFilter = false;
       this.getField(this.view.parentProperty).canEdit = false;
     }
+ 
+  //// Begins-added to have the additional filter clause and tabid..Mallikarjun M
+ //URL example:http://localhost:8080/openbravo/?tabId=186&filterClause=e.businessPartner.searchKey%3D%27mcgiver%27&replaceDefaultFilter=true&
+    if (this.view.tabId === this.view.standardWindow.additionalFilterTabId) {
+        
+      if (!this.filterClause || this.view.standardWindow.replaceDefaultFilter==='true') {
+        this.filterClause = unescape(this.view.standardWindow.additionalFilterClause);
+      } else if (this.filterClause) {
+        this.filterClause = '((' + this.filterClause + ') and (' +unescape(this.view.standardWindow.additionalFilterClause)  + '))';
+      }
+    }
+ //// Ends..
+  
   },
   
   show: function(){
@@ -472,7 +485,7 @@
     } else if (length === 0) {
       newValue = '&nbsp;';
     } else {
-      newValue = '' + length;
+      newValue = length;
     }
     if (this.filterEditor && this.filterEditor.getEditForm()) {
       this.filterEditor.getEditForm().setValue(isc.OBViewGrid.EDIT_LINK_FIELD_NAME, newValue);
@@ -772,6 +785,10 @@
         // remove the filter clause we don't want to use it anymore
         this.filterClause = null;
       }
+    } else if (this.forceRefresh) {
+      // add a dummy criteria to force a fetch
+      criteria.criteria.push(isc.OBRestDataSource.getDummyCriterion());
+      delete this.forceRefresh;
     } else {
       // remove the _dummy
       for (i = 0; i < criteria.criteria.length; i++) {
@@ -896,6 +913,7 @@
   
   clearFilter: function(){
     delete this.filterClause;
+    this.forceRefresh = true;
     this.filterEditor.getEditForm().clearValues();
     this.filterEditor.performAction();
   },
@@ -1089,7 +1107,7 @@
     var selectionLength = selection.getLength();
     var newValue = '&nbsp;';
     if (selectionLength > 0) {
-      newValue = selectionLength + '';
+      newValue = selectionLength;
     }
     if (this.filterEditor) {
       this.filterEditor.getEditForm().setValue(this.getCheckboxField().name, newValue);
@@ -2194,7 +2212,7 @@
       }
       this.showMember(2 + offset);
       this.showMember(1 + offset);
-      this.showMember(0 + offset);
+      this.showMember(offset);
     }
   },
   
@@ -2207,7 +2225,7 @@
       this.hideMember(0);
       offset = 1;
     }
-    this.showMember(0 + offset);
+    this.showMember(offset);
     if (this.editButton.showable()) {
       this.showMember(1 + offset);
       this.showMember(2 + offset);
@@ -2271,7 +2289,7 @@
       return;
     }
     // already visible
-    if (this.members[memberNo] && this.members[memberNo].visibility === isc.Canvas.INHERIT || this.members[memberNo].visibility === isc.Canvas.VISIBLE) {
+    if (this.members[memberNo] && (this.members[memberNo].visibility === isc.Canvas.INHERIT || this.members[memberNo].visibility === isc.Canvas.VISIBLE)) {
       return;
     }
     this.Super('showMember', arguments);