diff app/controller/Orte.js @ 292:73a2c114db64

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:06 +0200
parents 4db982514a5f
children 6a7a9267e00f
line wrap: on
line diff
--- a/app/controller/Orte.js	Fri Aug 09 15:00:06 2013 +0200
+++ b/app/controller/Orte.js	Fri Aug 09 15:00:06 2013 +0200
@@ -1,5 +1,8 @@
+/**
+ * Controller for Orte
+ */
 Ext.define('Lada.controller.Orte', {
-    extend: 'Ext.app.Controller',
+    extend: 'Lada.controller.Base',
     views: [
         'orte.List',
         'orte.Create'
@@ -15,20 +18,21 @@
     ],
     init: function() {
         console.log('Initialising the Orte controller');
+        this.callParent();
+    },
+    addListeners: function() {
         this.control({
-            // CSS like selector to select element in the viewport. See
-            // ComponentQuery documentation for more details.
             'ortelist': {
-                itemdblclick: this.editOrt
+                itemdblclick: this.editItem
             },
             'ortelist toolbar button[action=add]': {
-                click: this.addOrt
+                click: this.addItem
             },
             'ortelist toolbar button[action=delete]': {
-                click: this.deleteOrt
+                click: this.deleteItem
             },
             'ortecreate button[action=save]': {
-                click: this.saveOrt
+                click: this.saveItem
             },
             'ortecreate form': {
                 savesuccess: this.createSuccess,
@@ -40,7 +44,7 @@
             }
         });
     },
-    saveOrt: function(button) {
+    saveItem: function(button) {
         console.log('Saving Ort');
         var form = button.up('window').down('form');
         var fform = form.getForm();
@@ -84,38 +88,17 @@
         });
 
     },
-    addOrt: function(button) {
+    addItem: function(button) {
         console.log('Adding new Ort for Probe ' + button.probeId);
         var ort = Ext.create('Lada.model.Ort');
         ort.set('probeId', button.probeId);
         var view = Ext.widget('ortecreate', {model: ort});
     },
-    editOrt: function(grid, record) {
+    editItem: function(grid, record) {
         console.log('Editing Ort');
         var view = Ext.widget('ortecreate', {model: record});
         console.log("Loaded Ort with ID " + record.getId()); //outputs ID
     },
-    deleteOrt: function(button) {
-        // Get selected item in grid
-        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 Ort');
-            } else {
-                console.log('Cancel Deleting Ort');
-            }
-        });
-    },
     createSuccess: function(form, record, operation) {
         // Reload store
         var store = this.getOrteStore();
@@ -123,27 +106,11 @@
         var win = form.up('window');
         win.close();
     },
-    createFailure: function(form, record, operation) {
-        Ext.MessageBox.show({
-            title: 'Fehler beim Speichern',
-            msg: form.message,
-            icon: Ext.MessageBox.ERROR,
-            buttons: Ext.Msg.OK
-        });
-    },
     editSuccess: function(form, record, operation) {
         // Reload store
         var store = this.getOrteStore();
         store.reload();
         var win = form.up('window');
         win.close();
-    },
-    editFailure: function(form, record, operation) {
-        Ext.MessageBox.show({
-            title: 'Fehler beim Speichern',
-            msg: form.message,
-            icon: Ext.MessageBox.ERROR,
-            buttons: Ext.Msg.OK
-        });
     }
 });

http://lada.wald.intevation.org