details:   https://code.openbravo.com/erp/devel/pi/rev/d9584faf499b
changeset: 28121:d9584faf499b
user:      Inigo Sanchez <inigo.sanchez <at> openbravo.com>
date:      Sun Dec 13 18:52:55 2015 +0100
summary:   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.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
 |  21 ++++++++-
 1 files changed, 17 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r cca73bf2ef95 -r d9584faf499b 
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;

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to