changeset 109:2308094f5a8c

Added forms to add Orte
author Torsten Irländer <torsten.irlaender@intevation.de>
date Wed, 19 Jun 2013 14:10:25 +0200 (2013-06-19)
parents 6c69bbb61c65
children c4f97a5a9939
files app.js app/controller/Orte.js app/view/orte/Create.js app/view/orte/CreateForm.js
diffstat 4 files changed, 144 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Wed Jun 19 14:09:53 2013 +0200
+++ b/app.js	Wed Jun 19 14:10:25 2013 +0200
@@ -20,6 +20,7 @@
         'Proben',
         'Kommentare',
         'Sql',
+        'Orte',
         'Messungen'
 
     ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/controller/Orte.js	Wed Jun 19 14:10:25 2013 +0200
@@ -0,0 +1,90 @@
+Ext.define('Lada.controller.Orte', {
+    extend: 'Ext.app.Controller',
+    views: [
+        'orte.List',
+        'orte.Create'
+    ],
+    stores: [
+    ],
+    models: [
+        'Ort'
+    ],
+    init: function() {
+        console.log('Initialising the Orte controller');
+        this.control({
+            // CSS like selector to select element in the viewport. See
+            // ComponentQuery documentation for more details.
+            'ortelist': {
+                itemdblclick: this.editOrt
+            },
+            'ortelist toolbar button[action=add]': {
+                click: this.addOrt
+            },
+            'ortelist toolbar button[action=delete]': {
+                click: this.deleteOrt
+            },
+            'ortecreate form': {
+                savesuccess: this.createSuccess,
+                savefailure: this.createFailure
+            },
+            'orteedit form': {
+                savesuccess: this.editSuccess,
+                savefailure: this.editFailure
+            }
+        });
+    },
+    addOrt: function(button) {
+        console.log('Adding new Ort');
+        var view = Ext.widget('ortecreate');
+    },
+    editOrt: 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();
+                store.remove(selection);
+                store.sync();
+                console.log('Deleting Kommentar');
+            } else {
+                console.log('Cancel Deleting Kommentar');
+            }
+        });
+    },
+    createSuccess: function(form, record, operation) {
+        // Reload store
+        var store = this.getOrteStore();
+        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
+        });
+    },
+    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
+        });
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/orte/Create.js	Wed Jun 19 14:10:25 2013 +0200
@@ -0,0 +1,29 @@
+Ext.define('Lada.view.orte.Create', {
+    extend: 'Ext.window.Window',
+    alias: 'widget.ortecreate',
+
+    title: 'Maske für Orte',
+    // Make size of the dialog dependend of the available space.
+    // TODO: Handle resizing the browser window.
+    width: Ext.getBody().getViewSize().width - 30,
+    height: Ext.getBody().getViewSize().height - 30,
+    autoShow: true,
+    autoScroll: true,
+    modal: true,
+
+    requires: [
+        'Lada.view.orte.CreateForm'
+    ],
+    initComponent: function() {
+        var form = Ext.create('Lada.view.orte.CreateForm');
+        this.items = [form];
+        this.buttons = [
+            {
+                text: 'Speichern',
+                handler: form.commit,
+                scope: form
+            }
+        ];
+        this.callParent();
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/orte/CreateForm.js	Wed Jun 19 14:10:25 2013 +0200
@@ -0,0 +1,24 @@
+Ext.define('Lada.view.orte.CreateForm', {
+    extend: 'Lada.view.widgets.LadaForm',
+    model: 'Lada.model.Ort',
+    initComponent: function() {
+        this.items = [
+            //{
+            //    xtype: 'textfield',
+            //    name: 'erzeuger',
+            //    fieldLabel: 'Erzeuger'
+            //},
+            //{
+            //    xtype: 'datefield',
+            //    name: 'kdatum',
+            //    fieldLabel: 'Datum'
+            //},
+            //{
+            //    xtype: 'textareafield',
+            //    name: 'ktext',
+            //    fieldLabel: 'Text'
+            //}
+        ];
+        this.callParent();
+    }
+});

http://lada.wald.intevation.org