Fixes issue 29816: Process Button access changed when accessing from a subtab
authorCarlos Aristu <carlos.aristu@openbravo.com>
Mon, 08 Jun 2015 10:51:34 +0200
changeset 26874 9909424c0e02
parent 26873 8acbd2d2afa5
child 26876 727c9b6c55c2
Fixes issue 29816: Process Button access changed when accessing from a subtab
The problem was affecting only when displaying parent buttons after selecting a non focused child tab.
In this case, the WindowSettingsActionHandler is called when opening the window to get the role access for each button. Due to the lazy inizialization of the not focused tabs by default, in this moment is not possible to set the access for the right side toolbar buttons of those tabs.
Now, in the prepareFullChildView method which is executed the first time a child tab is selected, the buttons added in the toolbar for the child tab are added with the same state (readOnly) as they have in the parent tab.
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 07 21:27:32 2015 +0530
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Mon Jun 08 10:51:34 2015 +0200
@@ -869,7 +869,7 @@
   // It adds a tab with the whole view content based on the provided 'childView'.
   // If 'tab' parameter is provided, the 'childView' content is loaded inside the provided tab.
   prepareFullChildView: function (childView, tab) {
-    var length, i, actionButton, lastCalledSizeFunction;
+    var length, i, actionButton, toolBarButton, lastCalledSizeFunction;
 
     // Add buttons in parent to child. Note that currently it is only added one level.
     if (this.actionToolbarButtons && this.actionToolbarButtons.length > 0 && childView.showParentButtons) {
@@ -881,6 +881,12 @@
         actionButton.contextView = this; // Context is still parent view
         actionButton.toolBar = childView.toolBar;
         actionButton.view = childView;
+        if (this.toolBar && this.toolBar.rightMembers) {
+          toolBarButton = this.toolBar.rightMembers.find('property', actionButton.property);
+          if (toolBarButton && toolBarButton.readOnlyIf) {
+            actionButton.readOnlyIf = toolBarButton.readOnlyIf;
+          }
+        }
 
         childView.toolBar.rightMembers.push(actionButton);