[treeimpr] Related to issue 26455: 'Default Tree View Logic' now only affects
authorDavid Baz Fayos <david.baz@openbravo.com>
Mon, 23 Jun 2014 16:17:36 +0200
changeset 23859 4639ca577e0b
parent 23858 e3da458ad088
child 23860 391fdc807c26
[treeimpr] Related to issue 26455: 'Default Tree View Logic' now only affects
to the child views of the view where it applies. This is to fix the case where you cannot manually
change between the tree/grid view mode and then move to another different record (inside the same view)
preserving the previous manually set mode.
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	Sun Jun 22 12:27:58 2014 +0530
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Mon Jun 23 16:17:36 2014 +0200
@@ -389,10 +389,25 @@
 
   },
 
-  handleDefaultTreeView: function (parentContextInfo) {
+  // ** {{{ handleDefaultTreeView }}} **
+  //
+  // Evaluates the 'Default Tree View Logic' to show the grid view or the tree view
+  //
+  // Parameters:
+  // * {{{handleCurrent}}}: 'false' by default. It specifies if the logic should be applied in current record.
+  // * {{{handleChilds}}}: 'true' by default. It specifies if the logic should be applied in child records.
+  // * {{{parentContextInfo}}}: the context info of the parent. To ensure that the childs (if 'handleChilds' is 'true') have also the context info of its parent.
+  handleDefaultTreeView: function (handleCurrent, handleChilds, parentContextInfo) {
     var contextInfo, tabViewPane, length, i, p;
     contextInfo = this.getContextInfo(false, true, true);
 
+    if (!handleCurrent) {
+      handleCurrent = false;
+    }
+    if (!handleChilds) {
+      handleChilds = true;
+    }
+
     for (p in parentContextInfo) {
       // While evaluating the 'defaultTreeViewLogicIf' the parent contextInfo is needed
       // because based on the parent selected record, the current view will be shown
@@ -402,27 +417,30 @@
       }
     }
 
-    if (this.treeGrid && isc.isA.Function(this.defaultTreeViewLogicIf)) {
-      if (this.defaultTreeViewLogicIf(contextInfo)) {
-        if (!this.isShowingTree) {
-          if (this.treeGrid.getDataSource()) {
-            OB.ToolbarUtils.showTreeGrid(this);
-          } else {
-            this.defaultTreeView = true;
+    if (handleCurrent) {
+      if (this.treeGrid && isc.isA.Function(this.defaultTreeViewLogicIf)) {
+        if (this.defaultTreeViewLogicIf(contextInfo)) {
+          if (!this.isShowingTree) {
+            if (this.treeGrid.getDataSource()) {
+              OB.ToolbarUtils.showTreeGrid(this);
+            } else {
+              this.defaultTreeView = true;
+            }
           }
+        } else if (this.isShowingTree) {
+          OB.ToolbarUtils.hideTreeGrid(this);
         }
-      } else if (this.isShowingTree) {
-        OB.ToolbarUtils.hideTreeGrid(this);
       }
     }
 
-    if (this.childTabSet) {
+
+    if (handleChilds && this.childTabSet) {
       length = this.childTabSet.tabs.length;
       for (i = 0; i < length; i++) {
         tabViewPane = this.childTabSet.tabs[i].pane;
         if (tabViewPane.handleDefaultTreeView) {
           this.addPreferenceValues(contextInfo, tabViewPane);
-          tabViewPane.handleDefaultTreeView(contextInfo);
+          tabViewPane.handleDefaultTreeView(true, true, contextInfo);
         }
       }
     }