[Lada-commits] [PATCH 2 of 2] Apply new workflow in orte dialog

Wald Commits scm-commit at wald.intevation.org
Thu Dec 5 09:58:08 CET 2013


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1386233877 -3600
# Node ID 12231f31c1124552ab739fee96fa1da525f63c57
# Parent  b3e806045a5a4d863c0a9df65d5e0f934b700106
Apply new workflow in orte dialog.

diff -r b3e806045a5a -r 12231f31c112 app/controller/Orte.js
--- a/app/controller/Orte.js	Thu Dec 05 09:56:50 2013 +0100
+++ b/app/controller/Orte.js	Thu Dec 05 09:57:57 2013 +0100
@@ -5,7 +5,8 @@
     extend: 'Lada.controller.Base',
     views: [
         'orte.List',
-        'orte.Create'
+        'orte.Create',
+        'orte.CreateOrt'
     ],
     stores: [
         'Orte',
@@ -34,6 +35,12 @@
             'ortecreate button[action=save]': {
                 click: this.saveItem
             },
+            'ortecreate form button[action=newort]': {
+                click: this.createOrt
+            },
+            'createortdetail button[action=save]': {
+                click: this.saveNewOrt
+            },
             'ortecreate form': {
                 savesuccess: this.createSuccess,
                 savefailure: this.createFailure
@@ -44,6 +51,41 @@
             }
         });
     },
+    createOrt: function(button) {
+        console.log('button clicked');
+        var win = Ext.create('Lada.view.orte.CreateOrt',{});
+        win.show();
+    },
+    saveNewOrt: function(button) {
+        console.log('button clicked');
+
+        var form = button.up('window').down('form').getForm();
+        var ortdetailstore = Ext.getStore('Ortedetails');
+        var ortdetail = Ext.create('Lada.model.Ortdetail');
+        var fields = ['beschreibung', 'hoeheLand',
+                      'latitude', 'longitude', 'staatId', 'gemId'];
+        for (var i = fields.length - 1; i >= 0; i--){
+            var ffield = form.findField("ort_"+fields[i]);
+            ortdetail.set(fields[i], ffield.getValue());
+        }
+        ortdetailstore.add(ortdetail);
+        ortdetailstore.sync({
+            success: function(batch, options) {
+                console.log(batch);
+                var od = Ext.ComponentQuery.query('ortdetail');
+                console.log(od);
+                batch.operations[0].resultSet.records[0].data;
+                var response = batch.operations[0].resultSet.records[0].data;
+                od[0].setValue(response.ortId);
+                console.log('id:' + response.ortId);
+                button.up('window').close();
+            },
+            failure: function() {
+                console.log('Error on saving Ortdetails');
+                ortdetailstore.remove(ortdetail);
+            }
+        });
+    },
     saveItem: function(button) {
         console.log('Saving Ort');
         var form = button.up('window').down('form');
@@ -100,7 +142,7 @@
         console.log("Loaded Ort with ID " + record.getId()); //outputs ID
     },
     initEditWindow: function(record, readonly, owner) {
-        var view = Ext.widget('ortecreate', {model: record});
+        var view = Ext.widget('ortecreate', {model: record, edit: true});
         var ignore = Array();
         if (readonly) {
             var form = view.down('form');
diff -r b3e806045a5a -r 12231f31c112 app/view/orte/CreateForm.js
--- a/app/view/orte/CreateForm.js	Thu Dec 05 09:56:50 2013 +0100
+++ b/app/view/orte/CreateForm.js	Thu Dec 05 09:57:57 2013 +0100
@@ -7,8 +7,10 @@
     requires: [
         'Lada.view.widgets.Ortdetail',
         'Lada.view.widgets.Staat',
-        'Lada.view.widgets.Verwaltungseinheit'
+        'Lada.view.widgets.Verwaltungseinheit',
+        'Lada.view.orte.CreateOrt'
     ],
+    edit: false,
     initComponent: function() {
         this.items = [
             {
@@ -18,6 +20,9 @@
                 listeners: {
                     scope: this,
                     'change': function (field, newv, oldv, opts) {
+                        if (field.up('window')) {
+                            field.up('window').down('fieldset').show();
+                        }
                         var orte = Ext.getStore('Ortedetails');
                         var ort = orte.getById(newv);
                         var fields = ['beschreibung', 'bezeichnung', 'hoeheLand',
@@ -57,8 +62,16 @@
                 fieldLabel: 'Ortszusatz'
             },
             {
+                xtype: 'button',
+                name: 'newort',
+                text: 'Neuen Ort Anlegen',
+                hidden: this.edit,
+                action: 'newort'
+            },
+            {
                 xtype: 'fieldset',
                 title: 'Ortsangaben',
+                hidden: !this.edit,
                 defaults: {
                         labelWidth: 150
                 },


More information about the Lada-commits mailing list