Mercurial > lada > lada-client
comparison app/view/grid/FilterResult.js @ 856:e44070aa45d2
Implemented a 'Delete Button' in the ResultGrid. Proben can be deleted when they are not ReadOnly and the Users is the Owner of the Probe
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 10 Jul 2015 17:14:19 +0200 |
parents | d054732bc7a2 |
children | 03f39ddae596 |
comparison
equal
deleted
inserted
replaced
855:dff2798390f8 | 856:e44070aa45d2 |
---|---|
10 * Grid to list Proben | 10 * Grid to list Proben |
11 */ | 11 */ |
12 Ext.define('Lada.view.grid.FilterResult', { | 12 Ext.define('Lada.view.grid.FilterResult', { |
13 extend: 'Ext.grid.Panel', | 13 extend: 'Ext.grid.Panel', |
14 alias: 'widget.filterresultgrid', | 14 alias: 'widget.filterresultgrid', |
15 | |
16 requires: 'Lada.view.window.DeleteProbe', | |
15 | 17 |
16 store: null, //'ProbenList', | 18 store: null, //'ProbenList', |
17 | 19 |
18 multiSelect: true, | 20 multiSelect: true, |
19 | 21 |
118 */ | 120 */ |
119 setupColumns: function(cols) { | 121 setupColumns: function(cols) { |
120 var resultColumns = []; | 122 var resultColumns = []; |
121 var fields = []; | 123 var fields = []; |
122 | 124 |
125 fields.push(new Ext.data.Field({ | |
126 name: 'owner' | |
127 })); | |
128 fields.push(new Ext.data.Field({ | |
129 name: 'readonly' | |
130 })); | |
131 | |
123 resultColumns.push({ | 132 resultColumns.push({ |
124 header: 'RW', | 133 header: 'RW', |
125 dataIndex: 'readonly', | 134 dataIndex: 'readonly', |
126 sortable: false, | 135 sortable: false, |
127 width: 30, | 136 width: 30, |
128 renderer: function(value) { | 137 renderer: function(value, meta, record) { |
129 if (value) { | 138 if ( !value && record.get('owner')) { |
130 return '<img src="resources/img/view-time-schedule-baselined.png"/>'; | 139 return '<img src="resources/img/view-time-schedule-edit.png"/>'; |
131 } | 140 } |
132 return '<img src="resources/img/view-time-schedule-edit.png"/>'; | 141 return '<img src="resources/img/view-time-schedule-baselined.png"/>'; |
133 } | 142 } |
134 }); | 143 }); |
135 fields.push(new Ext.data.Field({ | 144 |
136 name: 'readonly' | |
137 })); | |
138 for (var i = cols.length - 1; i >= 0; i--) { | 145 for (var i = cols.length - 1; i >= 0; i--) { |
139 if (cols[i] === 'id') { | 146 if (cols[i] === 'id') { |
140 continue; | 147 continue; |
141 } | 148 } |
142 resultColumns.push(cols[i]); | 149 resultColumns.push(cols[i]); |
143 fields.push(new Ext.data.Field({ | 150 fields.push(new Ext.data.Field({ |
144 name: cols[i].dataIndex | 151 name: cols[i].dataIndex |
145 })); | 152 })); |
146 } | 153 } |
154 if (this.store.$className == 'Lada.store.ProbenList') { | |
155 // Add a Delete-Button | |
156 // TODO: Might need to be extended to Messprogramme | |
157 resultColumns.push({ | |
158 xtype: 'actioncolumn', | |
159 header: 'Aktionen', | |
160 sortable: false, | |
161 width: 30, | |
162 items: [{ | |
163 icon: '/resources/img/edit-delete.png', | |
164 tooltip: 'Löschen', | |
165 isDisabled: function(grid, rowIndex, colIndex) { | |
166 var rec = grid.getStore().getAt(rowIndex); | |
167 if ( rec.get('readonly') || !rec.get('owner')) { | |
168 return true; | |
169 } | |
170 return false; | |
171 }, | |
172 handler: function(grid, rowIndex, colIndex){ | |
173 var rec = grid.getStore().getAt(rowIndex); | |
174 | |
175 var winname = 'Lada.view.window.DeleteProbe'; | |
176 var win = Ext.create(winname, { | |
177 record: rec, | |
178 parentWindow: this | |
179 }); | |
180 win.show(); | |
181 win.initData(); | |
182 } | |
183 }] | |
184 }); | |
185 } | |
147 this.store.model.setFields(fields); | 186 this.store.model.setFields(fields); |
148 this.reconfigure(this.store, resultColumns); | 187 this.reconfigure(this.store, resultColumns); |
149 } | 188 } |
150 }); | 189 }); |