Fixes issue 25581: Display logic is not working fine using auxiliary input
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 12 Feb 2014 16:10:18 +0100
changeset 22029 f066861d7e8b
parent 22028 be31d39cd9fb
child 22030 4ea15b8e3510
Fixes issue 25581: Display logic is not working fine using auxiliary input

The problem was that the display logic was using an auxiliary input defined for the parent tab, but its value was being wrongly overwritten by the subtab (the tab being hidden/shown). I
t has been fixed by adding the subtab session properties only if they are not an auxiliary input in the parent tab.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
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/grid/ob-view-grid.js	Thu Feb 06 09:53:55 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed Feb 12 16:10:18 2014 +0100
@@ -1535,6 +1535,8 @@
       this.selectionUpdated();
     }
 
+    delete this.view.refreshingData;
+
     // no data and the grid is not visible, only do this is if the 
     // form is not in new mode
     if (this.data && this.data.getLength() === 0 && !this.isVisible() && !this.view.viewForm.isNew) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu Feb 06 09:53:55 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed Feb 12 16:10:18 2014 +0100
@@ -1365,11 +1365,16 @@
         // Calling getContextInfo with (false, true, true) in order to obtain also the value of the
         // session attributes of the form
         contextInfo = this.getContextInfo(false, true, true);
-        isc.addProperties(contextInfo, tabViewPane.sessionAttributes);
+        this.addSessionAttributes(contextInfo, tabViewPane);
         if (tabViewPane.showTabIf && !(tabViewPane.showTabIf(contextInfo))) {
           this.childTabSet.tabBar.members[i].hide();
           tabViewPane.hidden = true;
         } else {
+          if (!tabViewPane.data && !tabViewPane.refreshingData) {
+            // If the child tab does not have data yet, refresh it
+            tabViewPane.refreshingData = true;
+            tabViewPane.refresh();
+          }
           if (this.childTabSet.visibility === 'hidden') {
             this.childTabSet.show();
           }
@@ -1403,6 +1408,21 @@
     }
   },
 
+  // Adds to contextInfo the session attributes of the childView, 
+  // unless the session attribute is an auxiliary input of its parent tab
+  addSessionAttributes: function (contextInfo, childView) {
+    var auxInputs = {},
+        p;
+    if (this.viewForm && this.viewForm.auxInputs) {
+      auxInputs = this.viewForm.auxInputs;
+    }
+    for (p in childView.sessionAttributes) {
+      if (childView.sessionAttributes.hasOwnProperty(p) && !auxInputs.hasOwnProperty(p)) {
+        contextInfo[p] = childView.sessionAttributes[p];
+      }
+    }
+  },
+
   // set childs to refresh when they are made visible
   setChildsToRefresh: function () {
     var length, i;