details:   https://code.openbravo.com/erp/devel/pi/rev/7d16e05fa5bd
changeset: 22680:7d16e05fa5bd
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Tue Mar 11 16:21:47 2014 +0100
summary:   Fixes issue 25534: Problem when creating records in grouped grids

When a record was created in a grouped grid, the created record was not 
included in the grid until it was refreshed manually. Now it is updated 
automatically,
 its parent record is opened and the created record is scrolled to the middle 
of the grid.

Also, calling refreshCurrentRecord did not update the grouped grid, and 
closeProcessPopup did not update it either.

Fix reapplied after fixing 25947

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
        |  21 +++++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
        |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
    |   4 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
 |   4 +
 4 files changed, 29 insertions(+), 2 deletions(-)

diffs (85 lines):

diff -r 0c92bf8ef90f -r 7d16e05fa5bd 
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
     Tue Mar 11 12:56:41 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Tue Mar 11 16:21:47 2014 +0100
@@ -1492,6 +1492,12 @@
       storedFocusItem = this.getFocusItem();
     }
 
+    if (this.view.viewGrid.isGrouped && this.isNew) {
+      // If a new record is added in a grouped grid, 
+      // the grid has to be refreshed after the record has been actually saved
+      this.refreshGroupedGrid = true;
+    }
+
     // store the value of the current focus item
     if (this.getFocusItem() && this.saveFocusItemChanged !== 
this.getFocusItem()) {
       this.getFocusItem().blur(this, this.getFocusItem());
@@ -1517,7 +1523,7 @@
     callback = function (resp, data, req) {
       var index1, index2, view = form.view,
           localRecord, status = resp.status,
-          sessionProperties, keepSelection;
+          sessionProperties, keepSelection, gridRefreshCallback, theGrid, 
theId;
 
       if (this.hasOwnProperty('previousExplicitOffline')) {
         isc.Offline.explicitOffline = this.previousExplicitOffline;
@@ -1649,6 +1655,19 @@
           }
         }
 
+        if (this.refreshGroupedGrid) {
+          // Refresh the grid, open the root node of the new record, select 
the new recor and scroll it into view
+          theGrid = this.view.viewGrid;
+          theId = this.getValues()[OB.Constants.ID];
+          gridRefreshCallback = function () {
+            var newRecord = theGrid.data.find('id', theId);
+            theGrid.selectSingleRecord(newRecord);
+            theGrid.scrollToRow(theGrid.getRecordIndex(newRecord));
+          };
+          this.view.viewGrid.refreshGrid(gridRefreshCallback);
+          delete this.refreshGroupedGrid;
+        }
+
       } else if (status === isc.RPCResponse.STATUS_VALIDATION_ERROR && 
resp.errors) {
         form.handleFieldErrors(resp.errors);
         view.standardWindow.autoSaveDone(view, false);
diff -r 0c92bf8ef90f -r 7d16e05fa5bd 
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
     Tue Mar 11 12:56:41 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Tue Mar 11 16:21:47 2014 +0100
@@ -1627,7 +1627,7 @@
     //check whether newRecordsToBeIncluded contains records not part of the 
current grid and remove them.
     if (newRecordsToBeIncluded && newRecordsToBeIncluded.length > 0 && 
this.data) {
       for (i = 0; i < newRecordsToBeIncluded.length; i++) {
-        if (!this.data.findByKey(newRecordsToBeIncluded[i])) {
+        if (this.data.findByKey && 
!this.data.findByKey(newRecordsToBeIncluded[i])) {
           index = newRecordsToBeIncluded.indexOf(newRecordsToBeIncluded[i]);
           if (index !== -1) {
             newRecordsToBeIncluded.splice(index, 1);
diff -r 0c92bf8ef90f -r 7d16e05fa5bd 
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
 Tue Mar 11 12:56:41 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Tue Mar 11 16:21:47 2014 +0100
@@ -1757,6 +1757,10 @@
         if (me.viewGrid.data.updateCacheData) {
           me.viewGrid.data.updateCacheData(data, req);
         }
+        if (me.viewGrid.isGrouped) {
+          // if the grid is group update its values to show the updated data
+          me.viewGrid.setEditValues(recordIndex, data[0]);
+        }
         me.viewGrid.selectRecord(me.viewGrid.getRecord(recordIndex));
         me.viewGrid.refreshRow(recordIndex);
         me.viewGrid.redraw();
diff -r 0c92bf8ef90f -r 7d16e05fa5bd 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
      Tue Mar 11 12:56:41 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
      Tue Mar 11 16:21:47 2014 +0100
@@ -185,6 +185,10 @@
         }
         currentView.refresh(null, autosaveDone, recordsAfterRefresh);
       }
+      if (contextView.viewGrid.isGrouped) {
+        // if the grid is grouped refresh the grid to show the records properly
+        contextView.viewGrid.refreshGrid();
+      }
     };
 
     if (this.autosave) {

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to