fixed bug 16125: Fixed buttons display logic checking for '' in 2.50 style
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 04 Mar 2011 09:41:04 +0100
changeset 11016 bc7672c90274
parent 11015 c2efd93a7ff0
child 11019 8a8749019b3d
fixed bug 16125: Fixed buttons display logic checking for '' in 2.50 style
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl	Fri Mar 04 08:25:47 2011 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl	Fri Mar 04 09:41:04 2011 +0100
@@ -45,15 +45,9 @@
           <#if fieldDefinition.showIf != "">
           showIf: function(item, value, form, values) {            
             var context = form.view.getContextInfo(false, true, true),
-                currentValues = values || form.view.getCurrentValues(), i;
-
-            // Fixing null values to match 2.50 behaviour '' == null
-            for(i in currentValues) { 
-              if(currentValues.hasOwnProperty(i) && 
-                 currentValues[i] === null) {
-                currentValues[i] = '';
-              }
-            }
+                currentValues = values || form.view.getCurrentValues();
+            
+            OB.Utilities.fixNull250(currentValues);
 
             return context && (${fieldDefinition.showIf});
           },          
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl	Fri Mar 04 08:25:47 2011 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl	Fri Mar 04 09:41:04 2011 +0100
@@ -70,6 +70,7 @@
        <#if field.showIf != "">
        , displayIf: function(item, value, form, currentValues) {
          currentValues = currentValues || form.view.getCurrentValues();
+         OB.Utilities.fixNull250(currentValues);
          var context = form.view.getContextInfo(false, true, true);
          return context && (${field.showIf});
        }
@@ -77,6 +78,7 @@
        <#if field.readOnlyIf != "">
        , readOnlyIf: function(item, value, form, currentValues) {
          currentValues = currentValues || form.view.getCurrentValues();
+         OB.Utilities.fixNull250(currentValues);
          var context = form.view.getContextInfo(false, true, true);
          return context && (${field.readOnlyIf});
        }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Fri Mar 04 08:25:47 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js	Fri Mar 04 09:41:04 2011 +0100
@@ -545,3 +545,20 @@
 OB.Utilities.updateSmartClientComponentValue = function(/* Object */input, /* Object */ component){
   component.setValue(input.value);
 };
+
+//** {{{ OB.Utilities.fixNull250 }}} **
+//
+// Transforms null values into '' to adapt display logic to 2.50 behavior.
+//
+// Parameters:
+// * {{{currentValues}}}: array of values
+OB.Utilities.fixNull250 = function (currentValues){
+  var i;
+  for(i in currentValues) { 
+    if(currentValues.hasOwnProperty(i) && 
+       currentValues[i] === null) {
+      currentValues[i] = '';
+    }
+  }
+};
+