details:   https://code.openbravo.com/erp/devel/pi/rev/61602390f123
changeset: 20158:61602390f123
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Fri Apr 19 19:56:02 2013 +0200
summary:   Fixed issue 23598: Added 'tabIdsToAvoid' capabilities to 
'registerButton' function

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
                              |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views-toolbar.js
            |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form-toolbar-button.js
 |   4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
                                 |  52 ++++++---
 4 files changed, 38 insertions(+), 22 deletions(-)

diffs (165 lines):

diff -r 9236c5ce39d9 -r 61602390f123 
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
 Fri Apr 19 16:43:16 2013 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Fri Apr 19 19:56:02 2013 +0200
@@ -250,7 +250,7 @@
       length = this.iconToolbarButtons.length;
       for (i = 0; i < length; i++) {
         // note create a somewhat unique id by concatenating the tabid and the 
index
-        OB.ToolbarRegistry.registerButton(this.tabId + '_' + i, 
isc.OBToolbarIconButton, this.iconToolbarButtons[i], 200 + (i * 10), 
this.tabId, false);
+        OB.ToolbarRegistry.registerButton(this.tabId + '_' + i, 
isc.OBToolbarIconButton, this.iconToolbarButtons[i], 200 + (i * 10), 
this.tabId, null, false);
       }
     }
 
diff -r 9236c5ce39d9 -r 61602390f123 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views-toolbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views-toolbar.js
       Fri Apr 19 16:43:16 2013 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views-toolbar.js
       Fri Apr 19 19:56:02 2013 +0200
@@ -228,6 +228,6 @@
     keyboardShortcutId: 'ToolBar_ManageViews'
   };
 
-  OB.ToolbarRegistry.registerButton(manageViewButtonProperties.buttonType, 
isc.OBToolbarIconButton, manageViewButtonProperties, 320, null, false);
+  OB.ToolbarRegistry.registerButton(manageViewButtonProperties.buttonType, 
isc.OBToolbarIconButton, manageViewButtonProperties, 320, null, null, false);
 
 }());
\ No newline at end of file
diff -r 9236c5ce39d9 -r 61602390f123 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form-toolbar-button.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form-toolbar-button.js
    Fri Apr 19 16:43:16 2013 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form-toolbar-button.js
    Fri Apr 19 19:56:02 2013 +0200
@@ -71,7 +71,7 @@
     keyboardShortcutId: 'ToolBar_Personalization'
   };
 
-  
OB.ToolbarRegistry.registerButton(personalizationButtonProperties.buttonType, 
isc.OBToolbarIconButton, personalizationButtonProperties, 310, null, false);
+  
OB.ToolbarRegistry.registerButton(personalizationButtonProperties.buttonType, 
isc.OBToolbarIconButton, personalizationButtonProperties, 310, null, null, 
false);
 
   // and register the toolbar button the window personalization tab  
   windowPersonalizationTabButtonProperties = {
@@ -147,6 +147,6 @@
   };
 
   // register only for the window personalization tab
-  
OB.ToolbarRegistry.registerButton(windowPersonalizationTabButtonProperties.buttonType,
 isc.OBToolbarIconButton, windowPersonalizationTabButtonProperties, 320, 
'FF8081813157AED2013157BF6D810023', false);
+  
OB.ToolbarRegistry.registerButton(windowPersonalizationTabButtonProperties.buttonType,
 isc.OBToolbarIconButton, windowPersonalizationTabButtonProperties, 320, 
'FF8081813157AED2013157BF6D810023', null, false);
 
 }());
\ No newline at end of file
diff -r 9236c5ce39d9 -r 61602390f123 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Fri Apr 19 16:43:16 2013 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Fri Apr 19 19:56:02 2013 +0200
@@ -1678,17 +1678,18 @@
 };
 
 
-// ** {{{ OB.ToolbarUtils.createCloneButton(/*String*/ actionHandler, 
/*Array[String]*/ tabIds, /*String*/ askMsg, /*Integer*/ sortOrder, /*Boolean*/ 
editRecordAfterClone, /*String*/ buttonId, /*Boolean*/ overwriteIfExists}}} **
+// ** {{{ OB.ToolbarUtils.createCloneButton(/*String*/ actionHandler, 
/*Array[String]*/ tabIds, /*String*/ askMsg, /*Integer*/ sortOrder, /*Boolean*/ 
editRecordAfterClone, /*String*/ buttonId, /*Boolean*/ overwriteIfExists, 
/*Array[String]*/ tabIdsToAvoid}}} **
 // Automatically set up a clone button for the provided tabs
 // Parameters:
 // * {{{actionHandler}}}:  action handler which processes and returns the 
cloned record
-// * {{{tabIds}}}: array of tabIds where this button will be shown
+// * {{{tabIds}}}: (Optional, all tabs will be included by default) array of 
tabIds where this button will be shown
 // * {{{askMsg}}}: (Optional, 'OBUIAPP_WantToCloneRecord' by default) Text 
that will be displayed when the button be pressed.
 // * {{{sortOrder}}}: (Optional, '100' by default) Position in the toolbar of 
the clone button.
 // * {{{editRecordAfterClone}}}: (Optional, true by default) If the form edit 
view (of the cloned record) should be opened after clone it.
 // * {{{buttonId}}}: (Optional, random by default) Don't set it unless you 
plan to do advanced coding with this button (as, for example, overwrite it 
later in another place).
 // * {{{overwriteIfExists}}}: (Optional, false by default) To be able to 
overwrite a particular existing clone button. The buttonId should match with 
the overwritten one.
-OB.ToolbarUtils.createCloneButton = function (actionHandler, tabIds, askMsg, 
sortOrder, editRecordAfterClone, buttonId, overwriteIfExists) {
+// * {{{tabIdsToAvoid}}}: (Optional, no tabs to avoid by default) array of 
tabIds where this button should not be shown
+OB.ToolbarUtils.createCloneButton = function (actionHandler, tabIds, askMsg, 
sortOrder, editRecordAfterClone, buttonId, overwriteIfExists, tabIdsToAvoid) {
   var cloneButtonProps = isc.addProperties({}, 
isc.OBToolbar.CLONE_BUTTON_PROPERTIES);
 
   if (!askMsg) {
@@ -1737,20 +1738,24 @@
     isc.ask(askMsg, callback);
   };
 
-  OB.ToolbarRegistry.registerButton(buttonId, isc.OBToolbarIconButton, 
cloneButtonProps, sortOrder, tabIds, overwriteIfExists);
+  OB.ToolbarRegistry.registerButton(buttonId, isc.OBToolbarIconButton, 
cloneButtonProps, sortOrder, tabIds, tabIdsToAvoid, overwriteIfExists);
 };
 
 OB.ToolbarRegistry = {
   buttonDefinitions: [],
 
   // note tabIds is an array of strings, but maybe null/undefined
-  registerButton: function (buttonId, clazz, properties, sortOrder, tabIds, 
overwriteIfExists) {
+  registerButton: function (buttonId, clazz, properties, sortOrder, tabIds, 
tabIdsToAvoid, overwriteIfExists) {
     var length;
 
     if (tabIds && !isc.isA.Array(tabIds)) {
       tabIds = [tabIds];
     }
 
+    if (tabIdsToAvoid && !isc.isA.Array(tabIdsToAvoid)) {
+      tabIdsToAvoid = [tabIdsToAvoid];
+    }
+
     // declare the vars and the object which will be stored
     var i, index = 0,
         buttonDef;
@@ -1760,7 +1765,8 @@
       clazz: clazz,
       properties: properties,
       sortOrder: sortOrder,
-      tabIds: tabIds
+      tabIds: tabIds,
+      tabIdsToAvoid: tabIdsToAvoid
     };
 
     // already registered button handling
@@ -1799,10 +1805,11 @@
     //  btnDefinitionClass.create(btnDefinitionProperties);
     var result = [],
         j, resultIndex = 0,
-        i, validTabId, tabIds, length = this.buttonDefinitions.length,
-        tabIdsLength;
+        i, validTabId, tabIds, tabIdsToAvoid, length = 
this.buttonDefinitions.length,
+        tabIdsLength, tabIdsToAvoidLength;
     for (i = 0; i < length; i++) {
       tabIds = this.buttonDefinitions[i].tabIds;
+      tabIdsToAvoid = this.buttonDefinitions[i].tabIdsToAvoid;
       validTabId = !tabIds;
       if (tabIds) {
         tabIdsLength = tabIds.length;
@@ -1814,6 +1821,15 @@
         }
       }
       if (validTabId) {
+        tabIdsToAvoidLength = (tabIdsToAvoid && isc.isA.Array(tabIdsToAvoid) 
&& tabIdsToAvoid.length ? tabIdsToAvoid.length : 0);
+        for (j = 0; j < tabIdsToAvoidLength; j++) {
+          if (tabIdsToAvoid[j] === tabId) {
+            validTabId = false;
+            break;
+          }
+        }
+      }
+      if (validTabId) {
         result[resultIndex++] = 
this.buttonDefinitions[i].clazz.create(isc.clone(this.buttonDefinitions[i].properties));
       }
     }
@@ -1822,15 +1838,15 @@
 };
 
 //These are the icon toolbar buttons shown in all the tabs 
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES, 10, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES, 20, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVE_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.SAVE_BUTTON_PROPERTIES, 30, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES, 40, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.UNDO_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.UNDO_BUTTON_PROPERTIES, 50, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.DELETE_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.DELETE_BUTTON_PROPERTIES, 60, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.REFRESH_BUTTON_PROPERTIES, 70, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.EXPORT_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.EXPORT_BUTTON_PROPERTIES, 80, null, 
false);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES, 90, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES, 10, null, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES, 20, null, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVE_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.SAVE_BUTTON_PROPERTIES, 30, null, null, 
false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES, 40, null, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.UNDO_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.UNDO_BUTTON_PROPERTIES, 50, null, null, 
false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.DELETE_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.DELETE_BUTTON_PROPERTIES, 60, null, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.REFRESH_BUTTON_PROPERTIES, 70, null, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.EXPORT_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.EXPORT_BUTTON_PROPERTIES, 80, null, 
null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES, 90, 
null, null, false);
 
 //and add the direct link at the end
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.LINK_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.LINK_BUTTON_PROPERTIES, 300, null, 
false);
\ No newline at end of file
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.LINK_BUTTON_PROPERTIES.buttonType,
 isc.OBToolbarIconButton, isc.OBToolbar.LINK_BUTTON_PROPERTIES, 300, null, 
null, false);
\ No newline at end of file

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to