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

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


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1376053206 -7200
# Node ID e95662994c50ffa616f21fe50f629541036caa80
# Parent  fe51239321d9afa6fc54991805582fb3a4678cdc
Inherit from Base controller

diff -r fe51239321d9 -r e95662994c50 app/controller/MKommentare.js
--- a/app/controller/MKommentare.js	Fri Aug 09 15:00:06 2013 +0200
+++ b/app/controller/MKommentare.js	Fri Aug 09 15:00:06 2013 +0200
@@ -1,5 +1,8 @@
+/**
+ * Controller for Kommentare on Messungen
+ */
 Ext.define('Lada.controller.MKommentare', {
-    extend: 'Ext.app.Controller',
+    extend: 'Lada.controller.Base',
     views: [
         'mkommentare.Create'
     ],
@@ -11,20 +14,21 @@
     ],
     init: function() {
         console.log('Initialising the MKommentare controller');
+        this.callParent();
+    },
+    addListeners: function() {
         this.control({
-            // CSS like selector to select element in the viewport. See
-            // ComponentQuery documentation for more details.
             'mkommentarelist': {
-                itemdblclick: this.editKommentar
+                itemdblclick: this.editItem
             },
             'mkommentarelist toolbar button[action=add]': {
-                click: this.addKommentar
+                click: this.addItem
             },
             'mkommentarelist toolbar button[action=delete]': {
-                click: this.deleteKommentar
+                click: this.deleteItem
             },
             'mkommentarecreate button[action=save]': {
-                click: this.saveKommentar
+                click: this.saveItem
             },
             'mkommentarecreate form': {
                 savesuccess: this.createSuccess,
@@ -32,57 +36,23 @@
             }
         });
     },
-    saveKommentar: function(button) {
-        console.log('Saving MKommentar');
-        var form = button.up('window').down('form');
-        form.commit();
-    },
-    addKommentar: function(button) {
+    addItem: function(button) {
         console.log('Adding new MKommentar for Messung ' + button.parentId + ' Probe ' + button.probeId);
         var kommentar = Ext.create('Lada.model.MKommentar');
         kommentar.set('probeId', button.probeId);
         kommentar.set('messungsId', button.parentId);
         var view = Ext.widget('mkommentarecreate', {model: kommentar});
     },
-    editKommentar: function(grid, record) {
+    editItem: function(grid, record) {
         console.log('Editing Kommentar');
         var view = Ext.widget('mkommentarecreate', {model: record});
         console.log("Loaded MKommentar with ID " + record.getId()); //outputs ID
     },
-    deleteKommentar: 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 MKommentar');
-            } else {
-                console.log('Cancel Deleting MKommentar');
-            }
-        });
-    },
     createSuccess: function(form, record, operation) {
         // Reload store
         var store = this.getMKommentareStore();
         store.reload();
         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
-        });
     }
 });


More information about the Lada-commits mailing list