comparison app/controller/grid/Datensatzerzeuger.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 'datensatzerzeugergrid': { 21 'datensatzerzeugergrid': {
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 'datensatzerzeugergrid button[action=add]': { 28 'datensatzerzeugergrid button[action=add]': {
28 click: this.add 29 click: this.add
29 }, 30 },
30 'datensatzerzeugergrid button[action=delete]': { 31 'datensatzerzeugergrid 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('datensatzerzeugergrid')[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.
67 */ 73 */
68 cancelEdit: function(editor, context) { 74 cancelEdit: function(editor, context) {
69 if (!context.record.get('id') || 75 if (!context.record.get('id') ||
70 context.record.get('id') === '') { 76 context.record.get('id') === '') {
71 editor.getCmp().store.remove(context.record); 77 editor.getCmp().store.remove(context.record);
78 this.buttonToggle();
72 } 79 }
73 context.grid.getSelectionModel().deselect(context.record); 80 else {
81 this.buttonToggle(context.grid.getSelectionModel(), context.record);
82 }
74 }, 83 },
75 84
76 /** 85 /**
77 * This function adds a new row to add a Datensatzerzeuger 86 * This function adds a new row to add a Datensatzerzeuger
78 */ 87 */
120 }); 129 });
121 } 130 }
122 }); 131 });
123 grid.down('button[action=delete]').disable(); 132 grid.down('button[action=delete]').disable();
124 }, 133 },
125 /**
126 * Toggles the buttons in the toolbar
127 **/
128 activateButtons: function(rowModel, record) {
129 var grid = rowModel.view.up('grid');
130 this.buttonToggle(true, grid);
131 },
132
133 /**
134 * Toggles the buttons in the toolbar
135 **/
136 deactivateButtons: function(rowModel, record) {
137 var grid = rowModel.view.up('grid');
138 // Only disable buttons when nothing is selected
139 if (rowModel.selected.items == 0) {
140 this.buttonToggle(false, grid);
141 }
142 },
143 134
144 /** 135 /**
145 * Enables/Disables a set of buttons 136 * Enables/Disables a set of buttons
146 **/ 137 **/
147 buttonToggle: function(enabled, grid) { 138 buttonToggle: function(rowModel, record) {
148 if (!enabled) { 139 if (!Ext.Array.contains(Lada.funktionen, 4)) {
140 return;
141 }
142 var grid = Ext.ComponentQuery.query('datensatzerzeugergrid')[0];
143 if (!record) {
144 grid.down('button[action=delete]').disable();
145 }
146 if (record.get('readonly') ||
147 rowModel.selected.items.length === 0) {
149 grid.down('button[action=delete]').disable(); 148 grid.down('button[action=delete]').disable();
150 } 149 }
151 else { 150 else {
152 if (!grid.getPlugin('rowedit').editing) { 151 if (grid.getPlugin('rowedit').editing) {
153 //only enable buttons, when grid is not beeing edited 152 //only enable buttons, when grid is not beeing edited
153 grid.down('button[action=delete]').disable();
154 }
155 else {
154 grid.down('button[action=delete]').enable(); 156 grid.down('button[action=delete]').enable();
155 }
156 //else turn them off again!
157 else {
158 this.buttonToggle(false, grid);
159 } 157 }
160 } 158 }
161 } 159 }
162 }); 160 });
163

http://lada.wald.intevation.org