comparison app/controller/grid/MessprogrammKategorie.js @ 1039:77e22ad5cc84

Use user 'funktionen' attribute to set read/write status for stammdaten.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 19 Feb 2016 13:59:24 +0100
parents 15d8c64049d1
children fa422d69940c
comparison
equal deleted inserted replaced
1038:1251094e7500 1039:77e22ad5cc84
19 init: function() { 19 init: function() {
20 this.control({ 20 this.control({
21 'messprogrammkategoriegrid': { 21 'messprogrammkategoriegrid': {
22 edit: this.gridSave, 22 edit: this.gridSave,
23 canceledit: this.cancelEdit, 23 canceledit: this.cancelEdit,
24 select: this.activateButtons, 24 select: this.buttonToggle,
25 deselect: this.deactivateButtons 25 deselect: this.buttonToggle,
26 itemdblclick: this.edit
26 }, 27 },
27 'messprogrammkategoriegrid button[action=add]': { 28 'messprogrammkategoriegrid button[action=add]': {
28 click: this.add 29 click: this.add
29 }, 30 },
30 'messprogrammkategoriegrid button[action=delete]': { 31 'messprogrammkategoriegrid button[action=delete]': {
31 click: this.remove 32 click: this.remove
32 } 33 }
33 }); 34 });
35 },
36
37 edit: function() {
38 var grid = Ext.ComponentQuery.query('messprogrammkategoriegrid')[0];
39 grid.down('button[action=delete]').disable();
34 }, 40 },
35 41
36 /** 42 /**
37 * This function is called when the grids roweditor saves 43 * This function is called when the grids roweditor saves
38 * the record. 44 * the record.
119 }); 125 });
120 } 126 }
121 }); 127 });
122 grid.down('button[action=delete]').disable(); 128 grid.down('button[action=delete]').disable();
123 }, 129 },
124 /**
125 * Toggles the buttons in the toolbar
126 **/
127 activateButtons: function(rowModel, record) {
128 var grid = rowModel.view.up('grid');
129 this.buttonToggle(true, grid);
130 },
131
132 /**
133 * Toggles the buttons in the toolbar
134 **/
135 deactivateButtons: function(rowModel, record) {
136 var grid = rowModel.view.up('grid');
137 // Only disable buttons when nothing is selected
138 if (rowModel.selected.items == 0) {
139 this.buttonToggle(false, grid);
140 }
141 },
142 130
143 /** 131 /**
144 * Enables/Disables a set of buttons 132 * Enables/Disables a set of buttons
145 **/ 133 **/
146 buttonToggle: function(enabled, grid) { 134 buttonToggle: function(rowModel, record) {
147 if (!enabled) { 135 if (!Ext.Array.contains(Lada.funktionen, 4)) {
136 return;
137 }
138 var grid = Ext.ComponentQuery.query('messprogrammkategoriegrid')[0];
139 if (!record) {
140 grid.down('button[action=delete]').disable();
141 }
142 if (record.get('readonly') ||
143 rowModel.selected.items.length === 0) {
148 grid.down('button[action=delete]').disable(); 144 grid.down('button[action=delete]').disable();
149 } 145 }
150 else { 146 else {
151 if (!grid.getPlugin('rowedit').editing) { 147 if (grid.getPlugin('rowedit').editing) {
152 //only enable buttons, when grid is not beeing edited 148 //only enable buttons, when grid is not beeing edited
149 grid.down('button[action=delete]').disable();
150 }
151 else {
153 grid.down('button[action=delete]').enable(); 152 grid.down('button[action=delete]').enable();
154 } 153 }
155 //else turn them off again!
156 else {
157 this.buttonToggle(false, grid);
158 }
159 } 154 }
160 }, 155 }
161 }); 156 });
162 157
163 158

http://lada.wald.intevation.org