changeset 293:bd77b6055791

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:07 +0200
parents 73a2c114db64
children 92b475303806
files app/controller/Proben.js
diffstat 1 files changed, 14 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/Proben.js	Fri Aug 09 15:00:06 2013 +0200
+++ b/app/controller/Proben.js	Fri Aug 09 15:00:07 2013 +0200
@@ -1,5 +1,8 @@
+/**
+ * Controller for Proben
+ */
 Ext.define('Lada.controller.Proben', {
-    extend: 'Ext.app.Controller',
+    extend: 'Lada.controller.Base',
     views: [
         'proben.Edit',
         'proben.Create'
@@ -14,20 +17,21 @@
     ],
     init: function() {
         console.log('Initialising the Proben controller');
+        this.callParent();
+    },
+    addListeners: function() {
         this.control({
-            // CSS like selector to select element in the viewport. See
-            // ComponentQuery documentation for more details.
             'probenlist': {
-                itemdblclick: this.editProbe
+                itemdblclick: this.editItem
             },
             'probenlist toolbar button[action=add]': {
-                click: this.addProbe
+                click: this.addItem
             },
             'probencreate button[action=save]': {
-                click: this.saveProbe
+                click: this.saveItem
             },
             'probenedit button[action=save]': {
-                click: this.saveProbe
+                click: this.saveItem
             },
             'probencreate form': {
                 savesuccess: this.createSuccess,
@@ -39,16 +43,11 @@
             }
         });
     },
-    saveProbe: function(button) {
-        console.log('Saving Probe');
-        var form = button.up('window').down('form');
-        form.commit();
-    },
-    addProbe: function(button) {
+    addItem: function(button) {
         console.log('Adding new Probe');
         var view = Ext.widget('probencreate');
     },
-    editProbe: function(grid, record) {
+    editItem: function(grid, record) {
         console.log('Editing Probe');
         var id = record.get('probeId');
         var view = Ext.widget('probenedit', {modelId: id});
@@ -100,32 +99,16 @@
                 if (json) {
                     var probeId = json.data.probeId;
                     var probe = store.findRecord("probeId", probeId);
-                    this.editProbe(null, probe);
+                    this.editItem(null, probe);
                 }
             }
         });
     },
-    createFailure: function(form, record, response) {
-        Ext.MessageBox.show({
-            title: 'Fehler beim Speichern',
-            msg: form.message,
-            icon: Ext.MessageBox.ERROR,
-            buttons: Ext.Msg.OK
-        });
-    },
     editSuccess: function(form, record, response) {
         // Reload store
         var store = this.getProbenStore();
         store.reload();
         var win = form.up('window');
         win.close();
-    },
-    editFailure: function(form, record, response) {
-        Ext.MessageBox.show({
-            title: 'Fehler beim Speichern',
-            msg: form.message,
-            icon: Ext.MessageBox.ERROR,
-            buttons: Ext.Msg.OK
-        });
     }
 });

http://lada.wald.intevation.org