comparison app/view/widgets/LadaForm.js @ 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 0d6552bb28ea
children dec0893d38e3
comparison
equal deleted inserted replaced
279:d18465f7b66a 280:1afccc0cab90
115 for (var k in codes) { 115 for (var k in codes) {
116 translated[k] = Lada.getApplication().bundle.getMsg(codes[k]); 116 translated[k] = Lada.getApplication().bundle.getMsg(codes[k]);
117 } 117 }
118 return translated; 118 return translated;
119 }, 119 },
120 setReadOnly: function (bReadOnly) { 120 /**
121 * Will set the form into readonly state.
122 * @param {Boolean} Flag to indicate if the form should be set to readonly
123 * or not.
124 * @param {Array} [ignoreFields="[]"] A list of fieldnames to ignore.
125 */
126 setReadOnly: function (bReadOnly, ignoreFields) {
127 console.log(ignoreFields);
128 if(typeof(ignoreFields)==='undefined') {
129 ignoreFields = Array();
130 }
121 /* Iterate over all fields and set them readonly */ 131 /* Iterate over all fields and set them readonly */
122 if (bReadOnly) { 132 if (bReadOnly) {
123 this.getForm().getFields().each (function (field) { 133 this.getForm().getFields().each (function (field) {
134 // Check if the field name is in the list of fields to ignore
135 var ignore = false;
136 for (var i = ignoreFields.length - 1; i >= 0; i--){
137 console.log(ignoreFields[i] + "===" + field.getName());
138 if (ignoreFields[i] === field.getName(true)) {
139 ignore = true;
140 };
141 };
124 //field.setDisabled(bReadOnly); 142 //field.setDisabled(bReadOnly);
125 field.setReadOnly(true); 143 if (!ignore) {
144 field.setReadOnly(true);
145 }
126 }); 146 });
127 /* Iterate over all toolbars of lists and hide them */ 147 /* Iterate over all toolbars of lists and hide them */
128 var childs = this.query('toolbar'); 148 var childs = this.query('toolbar');
129 for (var i = childs.length - 1; i >= 0; i--){ 149 for (var i = childs.length - 1; i >= 0; i--){
130 childs[i].setVisible(false); 150 childs[i].setVisible(false);

http://lada.wald.intevation.org