diff 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
line wrap: on
line diff
--- a/app/controller/grid/PKommentar.js	Fri Mar 27 08:43:37 2015 +0100
+++ b/app/controller/grid/PKommentar.js	Fri Mar 27 09:38:13 2015 +0100
@@ -12,7 +12,7 @@
     init: function() {
         this.control({
             'pkommentargrid': {
-                edit: this.edit,
+                edit: this.gridSave,
                 canceledit: this.cancelEdit
             },
             'pkommentargrid button[action=add]': {
@@ -24,14 +24,27 @@
         });
     },
 
-    edit: function(editor, context) {
+    gridSave: function(editor, context) {
         context.record.save({
             success: function() {
                 context.grid.store.reload();
                 context.grid.up('window').initData();
             },
-            failure: function() {
-                // TODO
+            failure: function(request, response) {
+                var json = response.request.scope.reader.jsonData;
+                if (json) {
+                    if (json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
+                            +' #'+json.message,
+                            Lada.getApplication().bundle.getMsg(json.message));
+                    } else {
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
+                            Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
+                    }
+                } else {
+                    Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
+                        Lada.getApplication().bundle.getMsg('err.msg.response.body'));
+                }
             }
         });
     },
@@ -59,8 +72,21 @@
                     success: function() {
                         button.up('window').initData();
                     },
-                    failure: function() {
-                        // TODO
+                    failure: function(request, response) {
+                        var json = response.request.scope.reader.jsonData;
+                        if (json) {
+                            if (json.message){
+                                Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title')
+                                    +' #'+json.message,
+                                    Lada.getApplication().bundle.getMsg(json.message));
+                            } else {
+                                Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'),
+                                    Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
+                            }
+                        } else {
+                            Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'),
+                                Lada.getApplication().bundle.getMsg('err.msg.response.body'));
+                        }
                     }
                 });
             }

http://lada.wald.intevation.org