changeset 280:1afccc0cab90

Issue55: Added ignoreFields parameter to the setReadonly function to be able to ignore some fields when setting the form into read only state.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 08 Aug 2013 11:11:55 +0200
parents d18465f7b66a
children 12ef979e73ce
files app/view/widgets/LadaForm.js
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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');

http://lada.wald.intevation.org