[Lada-commits] [PATCH 2 of 3] Issue55: Added ignoreFields parameter to the setReadonly function to be able

Wald Commits scm-commit at wald.intevation.org
Thu Aug 8 11:15:13 CEST 2013


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1375953115 -7200
# Node ID 1afccc0cab90fe121644caf1adb68b2fde8ccb52
# Parent  d18465f7b66a1376fddb091f17fa0d401ab6f4f5
Issue55: Added ignoreFields parameter to the setReadonly function to be able
to ignore some fields when setting the form into read only state.

diff -r d18465f7b66a -r 1afccc0cab90 app/view/widgets/LadaForm.js
--- a/app/view/widgets/LadaForm.js	Wed Aug 07 15:57:35 2013 +0200
+++ b/app/view/widgets/LadaForm.js	Thu Aug 08 11:11:55 2013 +0200
@@ -117,12 +117,32 @@
         }
         return translated;
     },
-    setReadOnly: function (bReadOnly) {
+    /**
+     * Will set the form into readonly state.
+     * @param {Boolean} Flag to indicate if the form should be set to readonly
+     * or not.
+     * @param {Array} [ignoreFields="[]"] A list of fieldnames to ignore.
+     */
+    setReadOnly: function (bReadOnly, ignoreFields) {
+        console.log(ignoreFields);
+        if(typeof(ignoreFields)==='undefined') {
+            ignoreFields = Array();
+        }
         /* Iterate over all fields and set them readonly */
         if (bReadOnly) {
             this.getForm().getFields().each (function (field) {
+                // Check if the field name is in the list of fields to ignore
+                var ignore = false;
+                for (var i = ignoreFields.length - 1; i >= 0; i--){
+                    console.log(ignoreFields[i] + "===" + field.getName());
+                    if (ignoreFields[i] === field.getName(true)) {
+                        ignore = true;
+                    };
+                };
                 //field.setDisabled(bReadOnly);
-                field.setReadOnly(true);
+                if (!ignore) {
+                    field.setReadOnly(true);
+                }
             });
             /* Iterate over all toolbars of lists and hide them */
             var childs = this.query('toolbar');


More information about the Lada-commits mailing list