Fixed issue 31627:Fields with display logic equals to false cause js error
authorInigo Sanchez <inigo.sanchez@openbravo.com>
Sun, 13 Dec 2015 18:52:55 +0100
changeset 28121 d9584faf499b
parent 28120 cca73bf2ef95
child 28122 a26c11c3031d
Fixed issue 31627:Fields with display logic equals to false cause js error

The problem was when a display logic was false (not a condition evaluated
to false) an error is thrown in the console. This error warned about trivial
comparisons (false === false).

To resolved this problem it has been added some condition to check this special
case. When a display logic is false, it is avoid this unecessary comparasion.

Now when a display logic is false is avoid to make this trivial comparison.
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl	Thu Dec 10 11:57:11 2015 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl	Sun Dec 13 18:52:55 2015 +0100
@@ -40,21 +40,34 @@
             OB.Utilities.fixNull250(currentValues);
         <#list data.fieldHandler.fields as field>
         <#if field.readOnlyIf != "" && field.showIf == "">
-        // Applying readonly.
+        // Applying read only.
            f.disableItem('${field.name}', ${field.readOnlyIf});
-        <#elseif field.readOnlyIf == "" && field.showIf != "">
+        <#else>
+        <#if field.readOnlyIf == "" && field.showIf != "">
         // Applying display logic in grid.
         if (!this.view.isShowingForm) {
+        <#if field.showIf == "false">
+           f.disableItem('${field.name}', true);
+        <#else>
            f.disableItem('${field.name}', (${field.showIf}) === false);
+        </#if>
         }
-        <#elseif field.readOnlyIf != "" && field.showIf != "">
-        // Applying display logic and readonly in grid/form.
+        <#else>
+        <#if field.readOnlyIf != "" && field.showIf != "">
+        // Applying display logic and read only in grid/form.
         if (!this.view.isShowingForm) {
+        <#if field.showIf == "false">
+           // If display logic has a false value, it is only necessary take into account the read only logic.
+           f.disableItem('${field.name}', (${field.readOnlyIf}));
+        <#else>
            f.disableItem('${field.name}', (${field.readOnlyIf}) || (${field.showIf}) === false);
+        </#if>
         } else {
            f.disableItem('${field.name}', ${field.readOnlyIf});
         }
         </#if>
+        </#if>
+        </#if>
         </#list>
         // disable forced in case the fields are set as read only per role
         disabledFields = form.view.disabledFields;