details:   https://code.openbravo.com/erp/devel/pi/rev/e3c9611f5f63
changeset: 22671:e3c9611f5f63
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Mar 10 18:56:44 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.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
        |  22 +++++++++-
 
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, 30 insertions(+), 2 deletions(-)

diffs (86 lines):

diff -r 118f7eb0d6af -r e3c9611f5f63 
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
     Mon Mar 10 18:30:08 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Mon Mar 10 18:56:44 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,20 @@
           }
         }
 
+        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);
+            this.data.openFolder(theGrid.data.getParent(newRecord));
+            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 118f7eb0d6af -r e3c9611f5f63 
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 Mar 10 18:30:08 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Mon Mar 10 18:56:44 2014 +0100
@@ -1633,7 +1633,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 118f7eb0d6af -r e3c9611f5f63 
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 Mar 10 18:30:08 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Mon Mar 10 18:56:44 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 118f7eb0d6af -r e3c9611f5f63 
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
      Mon Mar 10 18:30:08 2014 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
      Mon Mar 10 18:56:44 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