diff app/controller/MKommentare.js @ 291:e95662994c50

Inherit from Base controller
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 09 Aug 2013 15:00:06 +0200
parents 62e116cd3e3b
children 6a7a9267e00f
line wrap: on
line diff
--- 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
-        });
     }
 });

http://lada.wald.intevation.org