Fixes issue 28501: Window is property loaded having read only tabs
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 30 Dec 2014 12:57:04 +0100
changeset 24111 67689c9dda24
parent 24110 578fa0f1f471
child 24112 72a34ed08cd2
Fixes issue 28501: Window is property loaded having read only tabs

There was a problem in the way read only tabs were initialized. It was caused by this changeset [1], which fixed a problem related with read only tabs loaded lazily. The problem is that under some circumstances the setReadOnly function of the standard view was called without it being fully initialized. The setReadOnly invokation ended up calling the OBViewGrid.resetEmptyMessage function, and tried to execute this line:

this.view.parentView.isShowingTree

The problem is that the parentView property of the view was not set yet, so an error was thrown. To fix this, now the code to update some view properties based in its uiPattern value is executed after the parentView property is properly set.

[1] https://code.openbravo.com/erp/devel/pi/rev/052c07be4a9ddd2b2a61bd60e948370c53482cb4
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	Wed Dec 24 13:29:10 2014 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Tue Dec 30 12:57:04 2014 +0100
@@ -264,17 +264,19 @@
 
     this.toolBar.updateButtonState(true, false, true);
 
-    // It will only enter if this is a lazy initialized tab
+    // Update the subtab visibility before the tabs are shown to the client
+    this.handleDefaultTreeView();
+    this.updateSubtabVisibility();
+  },
+
+  // updates some view properties based on its uiPattern
+  updateViewBasedOnUiPattern: function () {
     // this.standardWindow.getClass().uiPattern will only exists after setWindowSettings is executed
     if (this.standardWindow.getClass().uiPattern) {
       this.setReadOnly(this.standardWindow.getClass().uiPattern[this.tabId] === isc.OBStandardView.UI_PATTERN_READONLY);
       this.setSingleRecord(this.standardWindow.getClass().uiPattern[this.tabId] === isc.OBStandardView.UI_PATTERN_SINGLERECORD);
       this.setEditOrDeleteOnly(this.standardWindow.getClass().uiPattern[this.tabId] === isc.OBStandardView.UI_PATTERN_EDITORDELETEONLY);
     }
-
-    // Update the subtab visibility before the tabs are shown to the client
-    this.handleDefaultTreeView();
-    this.updateSubtabVisibility();
   },
 
   show: function () {
@@ -895,6 +897,8 @@
     // build the structure of the children
     childView.buildStructure();
 
+    childView.updateViewBasedOnUiPattern();
+
     var childTabDef = {
       title: childView.tabTitle,
       pane: childView