comparison app/view/widgets/LadaForm.js @ 361:8a3991b5c200

Only hide save buttons if there are no fields which should be ignore while setting the field to readonly.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 15 Aug 2013 14:05:08 +0200
parents dec0893d38e3
children de73dc41f1d3
comparison
equal deleted inserted replaced
360:302db31ac50a 361:8a3991b5c200
140 * @param {Boolean} Flag to indicate if the form should be set to readonly 140 * @param {Boolean} Flag to indicate if the form should be set to readonly
141 * or not. 141 * or not.
142 * @param {Array} [ignoreFields="[]"] A list of fieldnames to ignore. 142 * @param {Array} [ignoreFields="[]"] A list of fieldnames to ignore.
143 */ 143 */
144 setReadOnly: function (bReadOnly, ignoreFields) { 144 setReadOnly: function (bReadOnly, ignoreFields) {
145 console.log(ignoreFields);
146 if(typeof(ignoreFields)==='undefined') { 145 if(typeof(ignoreFields)==='undefined') {
147 ignoreFields = Array(); 146 ignoreFields = Array();
148 } 147 }
149 /* Iterate over all fields and set them readonly */ 148 /* Iterate over all fields and set them readonly */
150 if (bReadOnly) { 149 if (bReadOnly) {
165 /* Iterate over all toolbars of lists and hide them */ 164 /* Iterate over all toolbars of lists and hide them */
166 var childs = this.query('toolbar'); 165 var childs = this.query('toolbar');
167 for (var i = childs.length - 1; i >= 0; i--){ 166 for (var i = childs.length - 1; i >= 0; i--){
168 childs[i].setVisible(false); 167 childs[i].setVisible(false);
169 } 168 }
170 /* Find Save-Button and hide it */ 169 /*
171 var win = this.up('window'); 170 * Find Save-Button and hide it. Only hide it if there are not
172 var buttons = win.query('.button'); 171 * fields left in the form which are editable
173 for (var j = buttons.length - 1; j >= 0; j--){ 172 * */
174 if (buttons[j].text === 'Speichern') { 173 if (ignoreFields.length == 0) {
175 buttons[j].setVisible(false); 174 var win = this.up('window');
175 var buttons = win.query('.button');
176 for (var j = buttons.length - 1; j >= 0; j--){
177 if (buttons[j].text === 'Speichern') {
178 buttons[j].setVisible(false);
179 };
176 }; 180 };
177 }; 181 }
178 } 182 }
179 }, 183 },
180 parseResponse: function(response) { 184 parseResponse: function(response) {
181 var json = Ext.decode(response.responseText); 185 var json = Ext.decode(response.responseText);
182 if (json) { 186 if (json) {

http://lada.wald.intevation.org