details:   https://code.openbravo.com/erp/devel/pi/rev/13c3d71a21b2
changeset: 18522:13c3d71a21b2
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Thu Nov 08 11:14:58 2012 +0100
summary:   0022131: AD_Tab_Access for inactive tabs is causing javascript errors

If we mark as inactive a tab that is included in the tab_access for a 
particular role causes the following error when accessing to the window that 
includes the tab: "Cannot read property 'viewForm' of null". Added not null 
validation before accessing objects of view.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
 |  62 +++++----
 1 files changed, 32 insertions(+), 30 deletions(-)

diffs (75 lines):

diff -r e2134d58e0af -r 13c3d71a21b2 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
       Mon Nov 12 15:47:01 2012 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-window.js
       Thu Nov 08 11:14:58 2012 +0100
@@ -425,39 +425,41 @@
         tab = data.tabs[t];
         view = this.getView(tab.tabId);
         disabledFields = [];
-        for (i = 0; i < view.viewForm.getFields().length; i++) {
-          field = view.viewForm.getFields()[i];
-          if (tab.fields[field.name] !== undefined) {
-            field.updatable = tab.fields[field.name];
-            field.disabled = !tab.fields[field.name];
-            if (!tab.fields[field.name]) {
-              disabledFields.push(field.name);
+        if (view !== null) {
+          for (i = 0; i < view.viewForm.getFields().length; i++) {
+            field = view.viewForm.getFields()[i];
+            if (tab.fields[field.name] !== undefined) {
+              field.updatable = tab.fields[field.name];
+              field.disabled = !tab.fields[field.name];
+              if (!tab.fields[field.name]) {
+                disabledFields.push(field.name);
+              }
             }
           }
-        }
-        view.disabledFields = disabledFields;
-        for (i = 0; i < view.viewGrid.getFields().length; i++) {
-          field = view.viewGrid.getFields()[i];
-          if (tab.fields[field.name] !== undefined) {
-            field.editorProperties.updatable = tab.fields[field.name];
-            field.editorProperties.disabled = !tab.fields[field.name];
+          view.disabledFields = disabledFields;
+          for (i = 0; i < view.viewGrid.getFields().length; i++) {
+            field = view.viewGrid.getFields()[i];
+            if (tab.fields[field.name] !== undefined) {
+              field.editorProperties.updatable = tab.fields[field.name];
+              field.editorProperties.disabled = !tab.fields[field.name];
+            }
           }
-        }
-        for (i = 0; i < view.toolBar.rightMembers.length; i++) {
-          button = view.toolBar.rightMembers[i];
-          if (tab.tabId === button.contextView.tabId && button.property && 
!tab.fields[button.property]) {
-            button.readOnlyIf = alwaysReadOnly;
-            // looking for this button in subtabs
-            for (st = 0; st < this.views.length; st++) {
-              stView = this.views[st];
-              if (stView === view) {
-                continue;
-              }
-              for (stBtns = 0; stBtns < stView.toolBar.rightMembers.length; 
stBtns++) {
-                stBtn = stView.toolBar.rightMembers[stBtns];
-                if (stBtn.contextView === button.contextView && stBtn.property 
&& !tab.fields[stBtn.property]) {
-                  stBtn.readOnlyIf = alwaysReadOnly;
-                  break;
+          for (i = 0; i < view.toolBar.rightMembers.length; i++) {
+            button = view.toolBar.rightMembers[i];
+            if (tab.tabId === button.contextView.tabId && button.property && 
!tab.fields[button.property]) {
+              button.readOnlyIf = alwaysReadOnly;
+              // looking for this button in subtabs
+              for (st = 0; st < this.views.length; st++) {
+                stView = this.views[st];
+                if (stView === view) {
+                  continue;
+                }
+                for (stBtns = 0; stBtns < stView.toolBar.rightMembers.length; 
stBtns++) {
+                  stBtn = stView.toolBar.rightMembers[stBtns];
+                  if (stBtn.contextView === button.contextView && 
stBtn.property && !tab.fields[stBtn.property]) {
+                    stBtn.readOnlyIf = alwaysReadOnly;
+                    break;
+                  }
                 }
               }
             }

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to