comparison app/controller/grid/Status.js @ 1025:2329acae1705

Added Error handlers for Statuswerte
author Dustin Demuth <dustin@intevation.de>
date Fri, 12 Feb 2016 16:33:10 +0100
parents 3e9ff7786d2c
children 859e2e9859cd
comparison
equal deleted inserted replaced
1023:3e9ff7786d2c 1025:2329acae1705
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('sdatum', new Date());
43 context.record.save({ 43 context.record.save({
44 success: function() { 44 success: function(response) {
45 var i18n = Lada.getApplication().bundle;
46 var json = Ext.JSON.decode(response.responseText);
47
48 if(json) {
49 if (!json.success) {
50 if(json.message){
51 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
52 +' #'+json.message,
53 i18n.getMsg(json.message));
54 } else {
55 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
56 i18n.getMsg('err.msg.generic.body'));
57 }
58 } else {
59 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
60 i18n.getMsg('err.msg.generic.body'));
61 }
62 }
63
45 context.grid.initData(); 64 context.grid.initData();
46 var win = context.grid.up('window'); 65 var win = context.grid.up('window');
47 win.initData(); 66 win.initData();
48 try { 67 try {
49 win.parentWindow.initData(); 68 win.parentWindow.initData();
168 Ext.Ajax.request({ 187 Ext.Ajax.request({
169 url: 'lada-server/rest/status', 188 url: 'lada-server/rest/status',
170 jsonData: record.getData(), 189 jsonData: record.getData(),
171 method: 'POST', 190 method: 'POST',
172 success: function(response) { 191 success: function(response) {
192 var i18n = Lada.getApplication().bundle;
193 var json = Ext.JSON.decode(response.responseText);
194
195 if(json) {
196 if (!json.success) {
197 if(json.message){
198 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
199 +' #'+json.message,
200 i18n.getMsg(json.message));
201 } else {
202 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
203 i18n.getMsg('err.msg.generic.body'));
204 }
205 }
206 }
207
173 button.up('window').initData(); 208 button.up('window').initData();
174 button.up('grid').initData(); 209 button.up('grid').initData();
175 }, 210 },
176 failure: function(response) { 211 failure: function(response) {
177 // TODO sophisticated error handling, with understandable Texts 212 // TODO sophisticated error handling, with understandable Texts
178 var i18n = Lada.getApplication().bundle; 213 var i18n = Lada.getApplication().bundle;
179 var json = Ext.JSON.decode(response.responseText); 214 var json = Ext.JSON.decode(response.responseText);
180 if (json) { 215 if (json) {
181 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
182 formPanel.setMessages(json.errors, json.warnings);
183 }
184 if(json.message){ 216 if(json.message){
185 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title') 217 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
186 +' #'+json.message, 218 +' #'+json.message,
187 i18n.getMsg(json.message)); 219 i18n.getMsg(json.message));
188 } else { 220 } else {

http://lada.wald.intevation.org