[Lada-commits] [PATCH 11 of 56] Inherit from Base controller

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


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1376053207 -7200
# Node ID 841dc60824b5c3434442ff45e51121cf33e10d0a
# Parent  92b475303806d9fd8c2ca12132e7b4975f2b3c58
Inherit from Base controller

diff -r 92b475303806 -r 841dc60824b5 app/controller/Status.js
--- a/app/controller/Status.js	Fri Aug 09 15:00:07 2013 +0200
+++ b/app/controller/Status.js	Fri Aug 09 15:00:07 2013 +0200
@@ -1,5 +1,5 @@
 Ext.define('Lada.controller.Status', {
-    extend: 'Ext.app.Controller',
+    extend: 'Lada.controller.Base',
     views: [
         'status.Create'
     ],
@@ -8,24 +8,25 @@
     ],
     init: function() {
         console.log('Initialising the Status controller');
+        this.callParent();
+    },
+    addListeners: function() {
         this.control({
-            // CSS like selector to select element in the viewpzusatzwert. See
-            // ComponentQuery documentation for more details.
             'statuslist': {
-                itemdblclick: this.editStatus
+                itemdblclick: this.editItem
             },
             'statuslist toolbar button[action=add]': {
-                click: this.addStatus
+                click: this.addItem
             },
             'statuslist toolbar button[action=delete]': {
-                click: this.deleteStatus
+                click: this.deleteItem
             },
             'statuscreate form': {
                 savesuccess: this.createSuccess,
                 savefailure: this.createFailure
             },
             'statuscreate button[action=save]': {
-                click: this.saveStatus
+                click: this.saveItem
             },
             'statusedit form': {
                 savesuccess: this.editSuccess,
@@ -33,44 +34,18 @@
             }
         });
     },
-    saveStatus: function(button) {
-        console.log('Saving Status');
-        var form = button.up('window').down('form');
-        form.commit();
-    },
-    addStatus: function(button) {
+    addItem: function(button) {
         console.log('Adding new Status for Messung ' + button.parentId + ' in Probe ' + button.probeId);
         var zusatzwert = Ext.create('Lada.model.Status');
         zusatzwert.set('probeId', button.probeId);
         zusatzwert.set('messungsId', button.parentId);
         var view = Ext.widget('statuscreate', {model: zusatzwert});
     },
-    editStatus: function(grid, record) {
+    editItem: function(grid, record) {
         console.log('Editing Status');
         var view = Ext.widget('statuscreate', {model: record});
         console.log("Loaded Status with ID " + record.getId()); //outputs ID
     },
-    deleteStatus: 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 Kommentar');
-            } else {
-                console.log('Cancel Deleting Kommentar');
-            }
-        });
-    },
     createSuccess: function(form, record, operation) {
         // Reload store
         var store = this.getStatusStore();
@@ -78,14 +53,6 @@
         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.getStatusStore();
@@ -93,12 +60,4 @@
         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
-        });
-    }
 });


More information about the Lada-commits mailing list