Mercurial > lada > lada-client
comparison app/controller/grid/Status.js @ 994:092e245b13a4
draft implementation of the status-reset function: Todo: move this into a 'confirmation dialog'
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 07 Jan 2016 16:19:41 +0100 |
parents | 77ea9a5c5f1d |
children | bf7bb9583a40 |
comparison
equal
deleted
inserted
replaced
992:77ea9a5c5f1d | 994:092e245b13a4 |
---|---|
22 edit: this.gridSave, | 22 edit: this.gridSave, |
23 canceledit: this.cancelEdit, | 23 canceledit: this.cancelEdit, |
24 }, | 24 }, |
25 'statusgrid button[action=add]': { | 25 'statusgrid button[action=add]': { |
26 click: this.add | 26 click: this.add |
27 }, | |
28 'statusgrid button[action=reset]': { | |
29 click: this.reset | |
27 } | 30 } |
28 }); | 31 }); |
29 }, | 32 }, |
30 | 33 |
31 /** | 34 /** |
113 //Set the Date | 116 //Set the Date |
114 record.set('datum', new Date()); | 117 record.set('datum', new Date()); |
115 | 118 |
116 button.up('statusgrid').store.insert(lastrow, record); | 119 button.up('statusgrid').store.insert(lastrow, record); |
117 button.up('statusgrid').getPlugin('rowedit').startEdit(lastrow, 1); | 120 button.up('statusgrid').getPlugin('rowedit').startEdit(lastrow, 1); |
118 } | 121 }, |
122 | |
123 /** | |
124 * Reset | |
125 * This Function instructs the server to reset the current status | |
126 * WIP / TODO | |
127 * | |
128 **/ | |
129 reset: function(button) { | |
130 var s = button.up('window').down('messungform').getRecord().get('status'); | |
131 var messId = button.up('window').down('messungform').getRecord().get('id'); | |
132 var recentStatus = button.up('statusgrid').store.getById(s); | |
133 | |
134 //Set Status to 'Resetted' (8) | |
135 var record = recentStatus.copy(); | |
136 record.set('datum', new Date()); | |
137 record.set('statusWert', 8); | |
138 record.set('id', null); | |
139 record.set('text', null); | |
140 | |
141 Ext.Ajax.request({ | |
142 url: 'lada-server/status', | |
143 jsonData: record.getData(), | |
144 method: 'POST', | |
145 success: function(response) { | |
146 button.up('window').initData(); | |
147 }, | |
148 failure: function(response) { | |
149 // TODO sophisticated error handling, with understandable Texts | |
150 var json = Ext.JSON.decode(response.responseText); | |
151 if (json) { | |
152 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | |
153 formPanel.setMessages(json.errors, json.warnings); | |
154 } | |
155 if(json.message){ | |
156 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') | |
157 +' #'+json.message, | |
158 Lada.getApplication().bundle.getMsg(json.message)); | |
159 } else { | |
160 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
161 i18n.getMsg('err.msg.generic.body')); | |
162 } | |
163 } else { | |
164 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | |
165 i18n.getMsg('err.msg.generic.body')); | |
166 } | |
167 } | |
168 }); | |
169 | |
170 } | |
119 }); | 171 }); |