Mercurial > lada > lada-client
comparison app/controller/grid/Status.js @ 998:4bbb3da88c14
Statusreset: added a confirmation dialog and i18n
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Mon, 11 Jan 2016 11:36:35 +0100 |
parents | bf7bb9583a40 |
children | 5beb2581a989 |
comparison
equal
deleted
inserted
replaced
997:c943340176d4 | 998:4bbb3da88c14 |
---|---|
51 } | 51 } |
52 catch(e) { | 52 catch(e) { |
53 } | 53 } |
54 }, | 54 }, |
55 failure: function(request, response) { | 55 failure: function(request, response) { |
56 var i18n = Lada.getApplication().bundle; | |
56 var json = response.request.scope.reader.jsonData; | 57 var json = response.request.scope.reader.jsonData; |
57 if (json) { | 58 if (json) { |
58 if (json.message){ | 59 if (json.message){ |
59 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') | 60 Ext.Msg.alert(i18n.getMsg('err.msg.save.title') |
60 +' #'+json.message, | 61 +' #'+json.message, |
61 Lada.getApplication().bundle.getMsg(json.message)); | 62 i18n.getMsg(json.message)); |
62 } else { | 63 } else { |
63 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), | 64 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
64 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); | 65 i18n.getMsg('err.msg.generic.body')); |
65 } | 66 } |
66 } else { | 67 } else { |
67 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), | 68 Ext.Msg.alert(i18n.getMsg('err.msg.save.title'), |
68 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | 69 i18n.getMsg('err.msg.response.body')); |
69 } | 70 } |
70 } | 71 } |
71 }); | 72 }); |
72 }, | 73 }, |
73 | 74 |
125 * This Function instructs the server to reset the current status | 126 * This Function instructs the server to reset the current status |
126 * WIP / TODO | 127 * WIP / TODO |
127 * | 128 * |
128 **/ | 129 **/ |
129 reset: function(button) { | 130 reset: function(button) { |
131 var me = this; | |
132 var rstbutton = button; | |
133 var i18n = Lada.getApplication().bundle; | |
134 Ext.MessageBox.confirm( | |
135 i18n.getMsg('statusgrid.reset.mbox.title'), | |
136 i18n.getMsg('statusgrid.reset.mbox.text'), | |
137 function(btn) { | |
138 if (btn === 'yes') { | |
139 me.doReset(rstbutton); | |
140 } | |
141 }); | |
142 }, | |
143 | |
144 doReset: function(button) { | |
145 var i18n = Lada.getApplication().bundle; | |
146 | |
147 var resetStatusValue = 0; //TODO 8 | |
148 | |
130 var s = button.up('window').down('messungform').getRecord().get('status'); | 149 var s = button.up('window').down('messungform').getRecord().get('status'); |
131 var messId = button.up('window').down('messungform').getRecord().get('id'); | 150 var messId = button.up('window').down('messungform').getRecord().get('id'); |
132 var recentStatus = button.up('statusgrid').store.getById(s); | 151 var recentStatus = button.up('statusgrid').store.getById(s); |
133 | 152 |
134 //Set Status to 'Resetted' (8) | 153 //Set Status to 'Resetted' (8) |
135 if (recentStatus) { | 154 if (recentStatus) { |
136 var record = recentStatus.copy(); | 155 var record = recentStatus.copy(); |
137 record.set('datum', new Date()); | 156 record.set('datum', new Date()); |
138 record.set('statusWert', 8); | 157 record.set('statusWert', resetStatusValue); |
139 record.set('id', null); | 158 record.set('id', null); |
140 record.set('text', null); | 159 record.set('text', i18n.getMsg('statusgrid.resetText')); |
141 } | 160 } |
142 | 161 |
143 Ext.Ajax.request({ | 162 Ext.Ajax.request({ |
144 url: 'lada-server/status', | 163 url: 'lada-server/status', |
145 jsonData: record.getData(), | 164 jsonData: record.getData(), |
148 button.up('window').initData(); | 167 button.up('window').initData(); |
149 button.up('grid').initData(); | 168 button.up('grid').initData(); |
150 }, | 169 }, |
151 failure: function(response) { | 170 failure: function(response) { |
152 // TODO sophisticated error handling, with understandable Texts | 171 // TODO sophisticated error handling, with understandable Texts |
172 var i18n = Lada.getApplication().bundle; | |
153 var json = Ext.JSON.decode(response.responseText); | 173 var json = Ext.JSON.decode(response.responseText); |
154 if (json) { | 174 if (json) { |
155 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ | 175 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ |
156 formPanel.setMessages(json.errors, json.warnings); | 176 formPanel.setMessages(json.errors, json.warnings); |
157 } | 177 } |
158 if(json.message){ | 178 if(json.message){ |
159 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') | 179 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title') |
160 +' #'+json.message, | 180 +' #'+json.message, |
161 Lada.getApplication().bundle.getMsg(json.message)); | 181 i18n.getMsg(json.message)); |
162 } else { | 182 } else { |
163 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | 183 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
164 i18n.getMsg('err.msg.generic.body')); | 184 i18n.getMsg('err.msg.generic.body')); |
165 } | 185 } |
166 } else { | 186 } else { |
167 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), | 187 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), |
168 i18n.getMsg('err.msg.generic.body')); | 188 i18n.getMsg('err.msg.generic.body')); |
169 } | 189 } |
170 } | 190 } |
171 }); | 191 }); |
192 } | |
172 | 193 |
173 } | |
174 }); | 194 }); |