comparison app/controller/grid/Probenehmer.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 'probenehmergrid': { 21 'probenehmergrid': {
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 'probenehmergrid button[action=add]': { 28 'probenehmergrid button[action=add]': {
28 click: this.add 29 click: this.add
29 }, 30 },
30 'probenehmergrid button[action=delete]': { 31 'probenehmergrid 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('probenehmergrid')[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 probenehmer 86 * This function adds a new row to add a probenehmer
78 */ 87 */
119 }); 128 });
120 } 129 }
121 }); 130 });
122 grid.down('button[action=delete]').disable(); 131 grid.down('button[action=delete]').disable();
123 }, 132 },
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 133
143 /** 134 /**
144 * Enables/Disables a set of buttons 135 * Enables/Disables a set of buttons
145 **/ 136 **/
146 buttonToggle: function(enabled, grid) { 137 buttonToggle: function(rowModel, record) {
147 if (!enabled) { 138 if (!Ext.Array.contains(Lada.funktionen, 4)) {
139 return;
140 }
141 var grid = Ext.ComponentQuery.query('probenehmergrid')[0];
142 if (!record) {
143 grid.down('button[action=delete]').disable();
144 }
145 if (record.get('readonly') ||
146 rowModel.selected.items.length === 0) {
148 grid.down('button[action=delete]').disable(); 147 grid.down('button[action=delete]').disable();
149 } 148 }
150 else { 149 else {
151 if (!grid.getPlugin('rowedit').editing) { 150 if (grid.getPlugin('rowedit').editing) {
152 //only enable buttons, when grid is not beeing edited 151 //only enable buttons, when grid is not beeing edited
152 grid.down('button[action=delete]').disable();
153 }
154 else {
153 grid.down('button[action=delete]').enable(); 155 grid.down('button[action=delete]').enable();
154 } 156 }
155 //else turn them off again!
156 else {
157 this.buttonToggle(false, grid);
158 }
159 } 157 }
160 }, 158 }
161 }); 159 });
162

http://lada.wald.intevation.org