comparison app/controller/grid/Status.js @ 945:023e622f9551

Added the ability to work with "StatusWerten" which are delivered by the lada-server. To enable the uses of StatusWerte, the controller for the status grid, needed to be extended. In addition, the form and grid views of Messung and Status were updated.
author Dustin Demuth <dustin@intevation.de>
date Tue, 27 Oct 2015 16:46:58 +0100
parents 1f1467713c3f
children 5b86baa038bc
comparison
equal deleted inserted replaced
944:1f1467713c3f 945:023e622f9551
18 */ 18 */
19 init: function() { 19 init: function() {
20 this.control({ 20 this.control({
21 'statusgrid': { 21 'statusgrid': {
22 edit: this.gridSave, 22 edit: this.gridSave,
23 canceledit: this.cancelEdit 23 canceledit: this.cancelEdit,
24 select: this.toggleAllowedPermissions
24 }, 25 },
25 'statusgrid button[action=add]': { 26 'statusgrid button[action=add]': {
26 click: this.add 27 click: this.add
27 }, 28 },
28 'statusgrid button[action=delete]': { 29 'statusgrid button[action=delete]': {
79 */ 80 */
80 add: function(button) { 81 add: function(button) {
81 var record = Ext.create('Lada.model.Status', { 82 var record = Ext.create('Lada.model.Status', {
82 messungsId: button.up('statusgrid').recordId 83 messungsId: button.up('statusgrid').recordId
83 }); 84 });
84 button.up('statusgrid').store.insert(0, record); 85 var lastrow = button.up('statusgrid').store.count()
85 button.up('statusgrid').rowEditing.startEdit(0, 1); 86 button.up('statusgrid').store.insert(lastrow, record);
87 button.up('statusgrid').rowEditing.startEdit(lastrow, 1);
86 }, 88 },
87 89
88 /** 90 /**
89 * A row can be removed from the grid with the remove 91 * A row can be removed from the grid with the remove
90 * function. It asks the user for confirmation 92 * function. It asks the user for confirmation
119 } 121 }
120 }); 122 });
121 } 123 }
122 }); 124 });
123 grid.down('button[action=delete]').disable(); 125 grid.down('button[action=delete]').disable();
126 },
127
128 /**
129 * When a row in a grid is selected,
130 * this function checks if the row may be edited,
131 * or if the row can be removed
132 */
133 toggleAllowedPermissions: function(context, record, index){
134
135 //retrieve the readOnly parameters
136 var readonlyWin = context.view.up('window').record.get('readonly');
137
138 var readonlyRec = record.get('readonly');
139 var grid = context.view.up('grid');
140
141 //retrieve the last record of the store
142 var lastRecord = context.getStore().last()
143 //Check if remove is allowed
144 if (lastRecord == record &&
145 readonlyWin == false &&
146 readonlyRec == false) {
147 grid.down('button[action=delete]').enable();
148 }
149 else {
150 grid.down('button[action=delete]').disable();
151 }
152
153
154 //Check if edit is allowed
155 if (lastRecord == record &&
156 readonlyWin == false &&
157 readonlyRec == false) {
158 grid.getPlugin('rowedit').enable()
159 }
160 else {
161 grid.getPlugin('rowedit').disable()
162 }
124 } 163 }
164
125 }); 165 });

http://lada.wald.intevation.org