Fixed issue 29863: Title of process buttons are not showing the correct text.
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Thu, 04 Jun 2015 16:53:27 +0200
changeset 26855 672ff4b32ead
parent 26854 82e40910201d
child 26856 1fe773745b2d
Fixed issue 29863: Title of process buttons are not showing the correct text.

When a process button allows multiple selection, the text shown in the button was not correct.

The problem was that the code for handling the change of the text inside a process button, that allows multiple selection,
didn't exist before.
To fix this the code needed to deal with the change of the name of the button for multiple selection has been created.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js	Thu Jun 04 14:54:06 2015 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js	Thu Jun 04 16:53:27 2015 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2014 Openbravo SLU
+ * All portions are Copyright (C) 2011-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -28,6 +28,11 @@
   contextView: null,
   labelValue: {},
 
+  initWidget: function () {
+    this.originalTitle = this.title;
+    this.Super('initWidget', arguments);
+  },
+
   action: function () {
     this.runProcess();
   },
@@ -246,7 +251,7 @@
 
   updateState: function (record, hide, context, keepNonAutosave) {
     var currentValues = isc.shallowClone(record || this.contextView.getCurrentValues() || {}),
-        grid;
+        grid, buttonValue, label, buttonValues = [];
     // do not hide non autosave buttons when hidding the rest if keepNonAutosave === true
     var hideButton = hide && (!keepNonAutosave || this.autosave);
 
@@ -273,13 +278,12 @@
       this.visible = !this.displayIf || (context && this.displayIf(this.contextView.viewForm, currentValues, context));
       readonly = this.readOnlyIf && context && this.readOnlyIf(this.contextView.viewForm, currentValues, context);
 
-      var buttonValue = record[this.property];
+      buttonValue = record[this.property];
       if (buttonValue === '--') {
         buttonValue = 'CL';
       }
 
-      // Changing button name associated with a list is not allowed in multi record buttons.
-      var label = this.labelValue[buttonValue];
+      label = this.labelValue[buttonValue];
       if (!label) {
         if (this.realTitle) {
           label = this.realTitle;
@@ -302,8 +306,31 @@
         OB.Utilities.fixNull250(currentValues);
         this.visible = this.visible && (!this.displayIf || (context && this.displayIf(this.contextView.viewForm, currentValues, context)));
         readonly = readonly || (this.readOnlyIf && context && this.readOnlyIf(this.contextView.viewForm, currentValues, context));
+        buttonValue = selection[i][this.property];
+        if (buttonValue === '--') {
+          buttonValue = 'CL';
+        }
+        if (buttonValues.indexOf(buttonValue) === -1) {
+          buttonValues.add(buttonValue);
+        }
       }
 
+      if (buttonValues.length === 1) {
+        label = this.labelValue[buttonValues[0]];
+        if (!label) {
+          if (this.realTitle) {
+            label = this.realTitle;
+          } else {
+            label = this.title;
+          }
+        }
+        this.realTitle = label;
+        this.setTitle(label);
+      } else {
+        label = this.originalTitle;
+        this.realTitle = label;
+        this.setTitle(label);
+      }
     }
 
     // Even visible is correctly set, it is necessary to execute show() or hide()
@@ -317,7 +344,5 @@
     } else {
       this.enable();
     }
-
-
   }
 });
\ No newline at end of file