details:   https://code.openbravo.com/erp/devel/pi/rev/74d15eec44db
changeset: 24257:74d15eec44db
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu Aug 14 12:09:54 2014 +0200
summary:   Fixes issue 27297: Bad behavior when a record is created with lazy 
filtering

Fixed two problems:
- ResultSet was not being initialized if the records were created in a way 
other than using the toolbar buttons. To fix this, the code to initialize the 
ResultSet has been moved to the methods in charge of created the records in the 
grid/form view, instead of on the action methods of the buttons.
- Adaptive filtering was not working properly. To fix this, now after creating 
a new record in a grid whose ResultSet is not initialized, the first time that 
grid is filtered adaptive filtered will not be used, to force fetching the 
records that are stored in the server. From then on the adaptive filtering will 
work as usual.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
      |   4 ++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
      |  10 +++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
     |  19 +--------
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
 |  14 +++++++
 4 files changed, 31 insertions(+), 16 deletions(-)

diffs (108 lines):

diff -r de13ddecdc91 -r 74d15eec44db 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Thu Aug 14 11:25:22 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Thu Aug 14 12:09:54 2014 +0200
@@ -266,7 +266,11 @@
   },
 
   editNewRecord: function (preventFocus) {
+    var grid = this.view.viewGrid;
     this.clearValues();
+    if (grid.lazyFiltering && !isc.isA.ResultSet(grid.data)) {
+      OB.Utilities.createResultSetManually(grid);
+    }
     var ret = this.Super('editNewRecord', arguments);
     this.doEditRecordActions(preventFocus, true);
     return ret;
diff -r de13ddecdc91 -r 74d15eec44db 
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
     Thu Aug 14 11:25:22 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Thu Aug 14 12:09:54 2014 +0200
@@ -1700,6 +1700,11 @@
       this.actionAfterDataArrived = null;
     }
 
+
+    if (this.data.manualResultSet && !this.data.useClientFiltering) {
+      this.data.useClientFiltering = true;
+    }
+
     return ret;
   },
 
@@ -2804,6 +2809,11 @@
     } else {
       insertRow = rowNum + 1;
     }
+
+    if (this.lazyFiltering && !isc.isA.ResultSet(this.data)) {
+      OB.Utilities.createResultSetManually(this);
+    }
+
     this.createNewRecordForEditing(insertRow);
     this.startEditing(insertRow);
     this.recomputeCanvasComponents(insertRow);
diff -r de13ddecdc91 -r 74d15eec44db 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Thu Aug 14 11:25:22 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Thu Aug 14 12:09:54 2014 +0200
@@ -108,13 +108,6 @@
     action: function () {
       var view = this.view,
           grid = view.viewGrid;
-
-      if (grid.lazyFiltering && !isc.isA.ResultSet(grid.data)) {
-        grid.dataProperties.dataSource = grid.dataSource;
-        grid.dataProperties.initialData = [];
-        grid.dataProperties.resultSize = 100;
-        grid.setData(grid.createDataModel());
-      }
       // In case of no record selected getRecordIndex(undefined) returns -1,
       // which is the top position, other case it adds bellow current selected 
row.
       if (grid.getSelectedRecord()) {
@@ -137,15 +130,7 @@
 
   NEW_DOC_BUTTON_PROPERTIES: {
     action: function () {
-      var view = this.view,
-          grid = view.viewGrid;
-
-      if (grid.lazyFiltering && !isc.isA.ResultSet(grid.data)) {
-        grid.dataProperties.dataSource = grid.dataSource;
-        grid.dataProperties.initialData = [];
-        grid.dataProperties.resultSize = 100;
-        grid.setData(grid.createDataModel());
-      }
+      var view = this.view;
       view.newDocument();
     },
     buttonType: 'newDoc',
@@ -1529,6 +1514,8 @@
     }
   },
 
+
+
   addMembers: 'null',
 
   leftMembers: [],
diff -r de13ddecdc91 -r 74d15eec44db 
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
        Thu Aug 14 11:25:22 2014 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-utilities.js
        Thu Aug 14 12:09:54 2014 +0200
@@ -1288,4 +1288,18 @@
     }
   }
   return size;
+};
+
+//** {{{ OB.Utilities.createResultSetManually }}} **
+//
+// Creates a ResultSet manually for a grid
+// Parameters:
+//  * {{{grid}}} The grid whose ResultSet will be created manually
+OB.Utilities.createResultSetManually = function (grid) {
+  grid.dataProperties.dataSource = grid.dataSource;
+  grid.dataProperties.initialData = [];
+  grid.dataProperties.resultSize = 100;
+  grid.dataProperties.useClientFiltering = false;
+  grid.dataProperties.manualResultSet = true;
+  grid.setData(grid.createDataModel());
 };
\ No newline at end of file

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

Reply via email to