[Lada-commits] [PATCH 03 of 56] Move more methods into the BaseController

Wald Commits scm-commit at wald.intevation.org
Tue Aug 13 09:53:29 CEST 2013


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1376053093 -7200
# Node ID 12e7f0ef90b6d3a14c33248c5c02e28c96364601
# Parent  c509e9f6d4db089f5ceab1921e61dd7f3e43b609
Move more methods into the BaseController.

diff -r c509e9f6d4db -r 12e7f0ef90b6 app/controller/Base.js
--- a/app/controller/Base.js	Fri Aug 09 14:21:08 2013 +0200
+++ b/app/controller/Base.js	Fri Aug 09 14:58:13 2013 +0200
@@ -37,7 +37,11 @@
      * Method to save the kommentar in the database. The method is called when
      * the user clicks on the "Save" button
      */
-    saveItem: function(button) {},
+    saveItem: function(button) {
+        console.log('Saving ...');
+        var form = button.up('window').down('form');
+        form.commit();
+    },
     /**
      * Method to open a window to enter the values for a new kommentar.
      * The method is called when the user clicks on the "Add" button in the
@@ -57,15 +61,58 @@
      * The method is called when the user selects the item in the grid and
      * selects the delete button in the grid toolbar.
      */
-    deleteItem: function(button) {},
+    deleteItem: function(button) {
+        var grid = button.up('grid');
+        var selection = grid.getView().getSelectionModel().getSelection()[0];
+        Ext.MessageBox.confirm('Löschen', 'Sind Sie sicher?', function(btn){
+            if(btn === 'yes'){
+                var store = grid.getStore();
+                var deleteUrl = selection.getProxy().url + selection.getEidi();
+                Ext.Ajax.request({
+                    url: deleteUrl,
+                    method: 'DELETE',
+                    success: function(response, opts) {
+                        store.reload();
+                    }
+                });
+                console.log('Deleting ' + selection);
+            } else {
+                console.log('Cancel Deleting ' + selection);
+            }
+        });
+    },
     /**
-     * Method to trigger the action after successfull save (create or edit).
+     * Method to trigger the action after successfull save (create).
      * In this case the related store is refreshed and the window is closed.
      */
     createSuccess: function(form, record, operation) {},
     /**
-     * Method to trigger the action after save (create or edit) fails.
+     * Method to trigger the action after save (create) fails.
      * In this case a Message Boss with a general error is shown.
      */
-    createFailure: function(form, record, operation) {}
+    createFailure: function(form, record, operation) {
+        Ext.MessageBox.show({
+            title: 'Fehler beim Speichern',
+            msg: form.message,
+            icon: Ext.MessageBox.ERROR,
+            buttons: Ext.Msg.OK
+        });
+    },
+    /**
+     * Method to trigger the action after successfull save (edit).
+     * In this case the related store is refreshed and the window is closed.
+     */
+    editSuccess: function(form, record, operation) {},
+    /**
+     * Method to trigger the action after save ( edit) fails.
+     * In this case a Message Boss with a general error is shown.
+     */
+    editFailure: function(form, record, operation) {
+        Ext.MessageBox.show({
+            title: 'Fehler beim Speichern',
+            msg: form.message,
+            icon: Ext.MessageBox.ERROR,
+            buttons: Ext.Msg.OK
+        });
+    },
 });


More information about the Lada-commits mailing list