Mercurial > lada > lada-client
comparison app/controller/grid/PKommentar.js @ 701:f0bc5387abcc
Added failure - Messages
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 27 Mar 2015 09:38:13 +0100 |
parents | 8acb3123b46c |
children | 6e28ebbe1a73 |
comparison
equal
deleted
inserted
replaced
700:1e76aec72815 | 701:f0bc5387abcc |
---|---|
10 extend: 'Ext.app.Controller', | 10 extend: 'Ext.app.Controller', |
11 | 11 |
12 init: function() { | 12 init: function() { |
13 this.control({ | 13 this.control({ |
14 'pkommentargrid': { | 14 'pkommentargrid': { |
15 edit: this.edit, | 15 edit: this.gridSave, |
16 canceledit: this.cancelEdit | 16 canceledit: this.cancelEdit |
17 }, | 17 }, |
18 'pkommentargrid button[action=add]': { | 18 'pkommentargrid button[action=add]': { |
19 click: this.add | 19 click: this.add |
20 }, | 20 }, |
22 click: this.remove | 22 click: this.remove |
23 } | 23 } |
24 }); | 24 }); |
25 }, | 25 }, |
26 | 26 |
27 edit: function(editor, context) { | 27 gridSave: function(editor, context) { |
28 context.record.save({ | 28 context.record.save({ |
29 success: function() { | 29 success: function() { |
30 context.grid.store.reload(); | 30 context.grid.store.reload(); |
31 context.grid.up('window').initData(); | 31 context.grid.up('window').initData(); |
32 }, | 32 }, |
33 failure: function() { | 33 failure: function(request, response) { |
34 // TODO | 34 var json = response.request.scope.reader.jsonData; |
35 if (json) { | |
36 if (json.message){ | |
37 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') | |
38 +' #'+json.message, | |
39 Lada.getApplication().bundle.getMsg(json.message)); | |
40 } else { | |
41 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), | |
42 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); | |
43 } | |
44 } else { | |
45 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), | |
46 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | |
47 } | |
35 } | 48 } |
36 }); | 49 }); |
37 }, | 50 }, |
38 | 51 |
39 cancelEdit: function(editor, context) { | 52 cancelEdit: function(editor, context) { |
57 if (btn === 'yes') { | 70 if (btn === 'yes') { |
58 selection.destroy({ | 71 selection.destroy({ |
59 success: function() { | 72 success: function() { |
60 button.up('window').initData(); | 73 button.up('window').initData(); |
61 }, | 74 }, |
62 failure: function() { | 75 failure: function(request, response) { |
63 // TODO | 76 var json = response.request.scope.reader.jsonData; |
77 if (json) { | |
78 if (json.message){ | |
79 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title') | |
80 +' #'+json.message, | |
81 Lada.getApplication().bundle.getMsg(json.message)); | |
82 } else { | |
83 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), | |
84 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); | |
85 } | |
86 } else { | |
87 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), | |
88 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | |
89 } | |
64 } | 90 } |
65 }); | 91 }); |
66 } | 92 } |
67 }); | 93 }); |
68 } | 94 } |