comparison app/controller/grid/Status.js @ 1185:90ae675a1224 schema-update

Updated client status workflow and model.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 31 Aug 2016 15:58:49 +0200
parents 0497693d5b74
children 19855757a950
comparison
equal deleted inserted replaced
1184:be720d0473f6 1185:90ae675a1224
37 * On success it refreshes the windows which contains the grid 37 * On success it refreshes the windows which contains the grid
38 * it also tries to refresh the ProbeWindow and the messunggrid 38 * it also tries to refresh the ProbeWindow and the messunggrid
39 * On failure it displays a message 39 * On failure it displays a message
40 */ 40 */
41 gridSave: function(editor, context) { 41 gridSave: function(editor, context) {
42 context.record.set('sdatum', new Date()); 42 context.record.set('datum', new Date());
43 var wert = editor.getEditor().down('combobox[displayField=wert]').value;
44 var stufe = editor.getEditor().down('combobox[displayField=stufe]').value;
45 var kombis = Ext.data.StoreManager.get('statuskombi');
46 var kombiNdx = kombis.findBy(function(record, id) {
47 if (record.raw.statusStufe.id === stufe &&
48 record.raw.statusWert.id === wert
49 ) {
50 return true;
51 }
52 });
53 context.record.set('statusKombi', kombis.getAt(kombiNdx).get('id'));
43 context.record.save({ 54 context.record.save({
44 success: function(response) { 55 success: function(response) {
45 var i18n = Lada.getApplication().bundle; 56 var i18n = Lada.getApplication().bundle;
46 var json = Ext.JSON.decode(response.responseText); 57 var json = Ext.JSON.decode(response.responseText);
47 58
170 doReset: function(button) { 181 doReset: function(button) {
171 var i18n = Lada.getApplication().bundle; 182 var i18n = Lada.getApplication().bundle;
172 183
173 var resetStatusValue = 8; 184 var resetStatusValue = 8;
174 185
175 var s = button.up('window').down('messungform').getRecord().get('status'); 186 var s = button.up('window').down('messungform').getCurrentStatus();
176 var messId = button.up('window').down('messungform').getRecord().get('id'); 187 var messId = button.up('window').down('messungform').getRecord().get('id');
177 var recentStatus = button.up('statusgrid').store.getById(s); 188
178 189 if(!s) {
190 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
191 i18n.getMsg('err.msg.generic.body'));
192 return;
193 }
179 //Set Status to 'Resetted' (8) 194 //Set Status to 'Resetted' (8)
180 if (recentStatus) { 195 var kombis = Ext.data.StoreManager.get('statuskombi');
181 var record = recentStatus.copy(); 196 var stufe = kombis.getById(s.get('statusKombi')).raw.statusStufe.id;
182 record.set('datum', new Date()); 197 var kombiNdx = kombis.findBy(function(record, id) {
183 record.set('statusWert', resetStatusValue); 198 if(record.raw.statusStufe.id === stufe && record.raw.statusWert.id === 8) {
184 record.set('id', null); 199 return true;
185 record.set('text', i18n.getMsg('statusgrid.resetText')); 200 }
186 } 201 });
202 var record = s.copy();
203 record.set('datum', new Date());
204 record.set('statusKombi', kombis.getAt(kombiNdx).get('id'));
205 record.set('id', null);
206 record.set('text', i18n.getMsg('statusgrid.resetText'));
187 207
188 Ext.Ajax.request({ 208 Ext.Ajax.request({
189 url: 'lada-server/rest/status', 209 url: 'lada-server/rest/status',
190 jsonData: record.getData(), 210 jsonData: record.getData(),
191 method: 'POST', 211 method: 'POST',

http://lada.wald.intevation.org