details:   https://code.openbravo.com/erp/devel/pi/rev/439b1eac8cae
changeset: 17758:439b1eac8cae
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Aug 24 12:08:02 2012 +0200
summary:   Fixes issue 21411: Selected records are preserved when refreshing 
child views

Now, when a record is saved, its child tabs will be refreshed preserving the 
selection of the records.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     |   5 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     |   5 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 |  33 ++++++++-
 3 files changed, 34 insertions(+), 9 deletions(-)

diffs (115 lines):

diff -r ece91fb55374 -r 439b1eac8cae 
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
     Fri Aug 24 08:47:25 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Fri Aug 24 12:08:02 2012 +0200
@@ -1410,7 +1410,7 @@
     callback = function (resp, data, req) {
       var index1, index2, view = form.view,
           localRecord, status = resp.status,
-          sessionProperties;
+          sessionProperties, keepSelection;
 
       if (this.hasOwnProperty('previousExplicitOffline')) {
         isc.Offline.explicitOffline = this.previousExplicitOffline;
@@ -1473,7 +1473,8 @@
 
         view.viewGrid.markForRedraw();
 
-        view.refreshChildViews();
+        keepSelection = true;
+        view.refreshChildViews(keepSelection);
 
         // success invoke the action, if any there
         view.standardWindow.autoSaveDone(view, true);
diff -r ece91fb55374 -r 439b1eac8cae 
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
     Fri Aug 24 08:47:25 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Fri Aug 24 12:08:02 2012 +0200
@@ -1963,7 +1963,7 @@
   editComplete: function (rowNum, colNum, newValues, oldValues, 
editCompletionEvent, dsResponse) {
 
     var record = this.getRecord(rowNum),
-        editRow, editSession, autoSaveAction;
+        editRow, editSession, autoSaveAction, keepSelection;
 
     // a new id has been computed use that now    
     if (record && record._newId) {
@@ -1992,7 +1992,8 @@
     // if nothing else got selected, select ourselves then
     if (!this.getSelectedRecord()) {
       this.selectRecord(record);
-      this.view.refreshChildViews();
+      keepSelection = true;
+      this.view.refreshChildViews(keepSelection);
     } else if (this.getSelectedRecord() === record) {
       this.view.refreshChildViews();
     }
diff -r ece91fb55374 -r 439b1eac8cae 
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
 Fri Aug 24 08:47:25 2012 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Fri Aug 24 12:08:02 2012 +0200
@@ -799,8 +799,8 @@
     }
   },
 
-  doRefreshContents: function (doRefreshWhenVisible, forceRefresh) {
-
+  doRefreshContents: function (doRefreshWhenVisible, forceRefresh, 
keepSelection) {
+    var callback, me = this;
     // if not visible anymore, reset the view back
     if (!this.isViewVisible()) {
       if (this.isShowingForm) {
@@ -825,6 +825,11 @@
     // can be used by others to see that we are refreshing content
     this.refreshContents = true;
 
+    if (keepSelection) {
+      this.viewGrid.recordsSelectedBeforeRefresh = 
this.viewGrid.getSelectedRecords();
+      this.formVisibleBeforeRefresh = this.isShowingForm;
+    }
+
     // clear all our selections..
     // note the true parameter prevents autosave actions from happening
     // this should have been done before anyway
@@ -855,7 +860,25 @@
       this.switchFormGridVisibility();
     }
 
-    this.viewGrid.refreshContents();
+    if (keepSelection) {
+      callback = function () {
+        var length, i, recordIndex;
+        length = me.viewGrid.recordsSelectedBeforeRefresh.length;
+        for (i = 0; i < length; i++) {
+          recordIndex = 
me.viewGrid.getRecordIndex(me.viewGrid.recordsSelectedBeforeRefresh[i]);
+          me.viewGrid.selectRecord(recordIndex);
+        }
+        if (me.formVisibleBeforeRefresh) {
+          me.switchFormGridVisibility();
+        }
+        delete me.formVisibleBeforeRefresh;
+        delete me.viewGrid.recordsSelectedBeforeRefresh;
+      };
+    } else {
+      callback = null;
+    }
+
+    this.viewGrid.refreshContents(callback);
 
     this.toolBar.updateButtonState(true);
 
@@ -868,7 +891,7 @@
     this.refreshContents = false;
   },
 
-  refreshChildViews: function () {
+  refreshChildViews: function (keepSelection) {
     var i, length, tabViewPane;
 
     if (this.childTabSet) {
@@ -877,7 +900,7 @@
         tabViewPane = this.childTabSet.tabs[i].pane;
         // force a refresh, only the visible ones will really 
         // be refreshed
-        tabViewPane.doRefreshContents(true);
+        tabViewPane.doRefreshContents(true, null, keepSelection);
       }
     }
   },

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to