changeset 149:26ac4c99f8c4

Added Orte.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 01 Jul 2013 17:05:03 +0200
parents ed7fb4fa32dc
children 13869814cdb8
files app.js app/controller/Orte.js app/controller/Proben.js app/model/Ort.js app/view/orte/Create.js app/view/orte/CreateForm.js app/view/orte/List.js
diffstat 7 files changed, 175 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app.js	Mon Jul 01 17:05:03 2013 +0200
@@ -29,9 +29,9 @@
         'Sql',
         'Proben',
         'Zusatzwerte',
-        'Kommentare'
+        'Kommentare',
+        'Orte'
         //'Sql',
-        //'Orte',
         //'Messungen'
     ]
 });
--- a/app/controller/Orte.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app/controller/Orte.js	Mon Jul 01 17:05:03 2013 +0200
@@ -5,6 +5,10 @@
         'orte.Create'
     ],
     stores: [
+        'Orte',
+        'Ortedetails',
+        'Staaten',
+        'Verwaltungseinheiten'
     ],
     models: [
         'Ort'
@@ -23,6 +27,9 @@
             'ortelist toolbar button[action=delete]': {
                 click: this.deleteOrt
             },
+            'ortecreate button[action=save]': {
+                click: this.saveOrt
+            },
             'ortecreate form': {
                 savesuccess: this.createSuccess,
                 savefailure: this.createFailure
@@ -33,9 +40,16 @@
             }
         });
     },
+    saveOrt: function(button) {
+        console.log('Saving Ort');
+        var form = button.up('window').down('form');
+        form.commit();
+    },
     addOrt: function(button) {
-        console.log('Adding new Ort');
-        var view = Ext.widget('ortecreate');
+        console.log('Adding new Ort for Probe ' + button.probeId);
+        var ort = Ext.create('Lada.model.Ort');
+        ort.set('probeId', button.probeId);
+        var view = Ext.widget('ortecreate', {model: ort});
     },
     editOrt: function(grid, record) {
         console.log('Editing Ort');
--- a/app/controller/Proben.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app/controller/Proben.js	Mon Jul 01 17:05:03 2013 +0200
@@ -8,8 +8,8 @@
         'Proben',
         'Zusatzwerte',
         'Probenzusatzwerte',
-        'Kommentare'
-    //    'Orte',
+        'Kommentare',
+        'Orte'
     //    'Messungen',
     ],
     init: function() {
@@ -51,13 +51,20 @@
                 probeId: id
             }
         });
-        // Load Kommentare 
+        // Load Kommentare
         var kstore = this.getKommentareStore();
         kstore.load({
             params: {
                 probeId: id
             }
         });
+        // Load Orte
+        var ostore = this.getOrteStore();
+        ostore.load({
+            params: {
+                probeId: id
+            }
+        });
         console.log("Loaded Probe with ID " + record.getId()); //outputs ID
     },
     createSuccess: function(form, record, operation) {
--- a/app/model/Ort.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app/model/Ort.js	Mon Jul 01 17:05:03 2013 +0200
@@ -1,23 +1,15 @@
 Ext.define('Lada.model.Ort', {
     extend: 'Ext.data.Model',
     fields: [
-        {name: "ort"},
-        {name: "ortId", mapping:"ort.ortId", type: 'int'},
-        {name: "otyp", mapping:"ort.otyp"},
-        {name: "bezeichnung", mapping:"ort.bezeichnung"},
-        {name: "beschreibung", mapping:"ort.beschreibung"},
-        {name: "gemId", mapping:"ort.gemId"},
-        {name: "staatId", mapping:"ort.staatId"},
-        {name: "unscharf", mapping:"ort.unscharf"},
-        {name: "nutsCode", mapping:"ort.nutsCode"},
-        {name: "koordXExtern", mapping:"ort.koordXExtern"},
-        {name: "koordYExtern", mapping:"ort.koordYExtern"},
-        {name: "hoeheLand", mapping:"ort.hoeheLand", type: 'float'},
-        {name: "letzteAenderung", mapping:"ort.letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()},
-        {name: "latitude", mapping:"ort.latitude", type: 'float'},
-        {name: "longitude", mapping:"ort.longitude", type: 'float'}
+        // Field from the l_ort table
+        {name: "portId", type: 'int'},
+        {name: "ortId", type: 'int'},
+        {name: "probeId"},
+        {name: "ortsTyp"},
+        {name: "ortzusatztext"},
+        {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()}
     ],
-    idProperty: "ortId",
+    idProperty: "portId",
     proxy: {
         type: 'rest',
         appendId: true, //default
--- a/app/view/orte/Create.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app/view/orte/Create.js	Mon Jul 01 17:05:03 2013 +0200
@@ -3,10 +3,6 @@
     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,
@@ -20,8 +16,8 @@
         this.buttons = [
             {
                 text: 'Speichern',
-                handler: form.commit,
-                scope: form
+                scope: form,
+                action: 'save'
             }
         ];
         this.callParent();
--- a/app/view/orte/CreateForm.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app/view/orte/CreateForm.js	Mon Jul 01 17:05:03 2013 +0200
@@ -1,24 +1,99 @@
 Ext.define('Lada.view.orte.CreateForm', {
     extend: 'Lada.view.widgets.LadaForm',
     model: 'Lada.model.Ort',
+    requires: [
+        'Lada.view.widgets.Ortdetail',
+        'Lada.view.widgets.Staat',
+        'Lada.view.widgets.Verwaltungseinheit'
+    ],
     initComponent: function() {
         this.items = [
-            //{
-            //    xtype: 'textfield',
-            //    name: 'erzeuger',
-            //    fieldLabel: 'Erzeuger'
-            //},
-            //{
-            //    xtype: 'datefield',
-            //    name: 'kdatum',
-            //    fieldLabel: 'Datum'
-            //},
-            //{
-            //    xtype: 'textareafield',
-            //    name: 'ktext',
-            //    fieldLabel: 'Text'
-            //}
+            {
+                xtype: 'ortdetail',
+                name: 'ortId',
+                fieldLabel: 'Ort',
+                listeners: {
+                    scope: this,
+                    'change': function (field, newv, oldv, opts) {
+                        console.log(field, oldv, newv, opts);
+                        var orte = Ext.getStore('Ortedetails');
+                        var ort = orte.getById(newv);
+                        var fields = ['beschreibung', 'bezeichnung', 'hoeheLand',
+                                      'latitude', 'longitude', 'staatId', 'gemId'];
+                        var form = this.getForm();
+                        if ( ort != undefined ) {
+                            console.log('Found ort');
+                            for (var i = fields.length - 1; i >= 0; i--){
+                                ffield = form.findField("ort_"+fields[i]);
+                                ffield.setValue(ort.get(fields[i]));
+                                ffield.setReadOnly(true);
+                            }
+                        } else {
+                            this.setReadOnly(false);
+                        }
+                    }
+                }
+            },
+            {
+                xtype: 'textfield',
+                name: 'ortsTyp',
+                maxLength: 1,
+                fieldLabel: 'Type'
+            },
+            {
+                xtype: 'textareafield',
+                name: 'ortszusatztext',
+                maxLength: 100,
+                fieldLabel: 'Ortszusatz'
+            },
+            {
+                xtype: 'fieldset',
+                title: 'Ortsangaben',
+                defaults: {
+                        labelWidth: 150
+                },
+                items: [
+                    {
+                        xtype: 'textfield',
+                        name: 'ort_beschreibung',
+                        fieldLabel: 'Beschreibung'
+                    },
+                    {
+                        xtype: 'textfield',
+                        name: 'ort_bezeichnung',
+                        fieldLabel: 'Bezeichnung'
+                    },
+                    {
+                        xtype: 'staat',
+                        name: 'ort_staatId',
+                        fieldLabel: 'Staat'
+                    },
+                    {
+                        xtype: 'verwaltungseinheiten',
+                        name: 'ort_gemId',
+                        fieldLabel: 'Gemeinde'
+                    },
+                    {
+                        xtype: 'textfield',
+                        name: 'ort_latitude',
+                        fieldLabel: 'Lat'
+                    },
+                    {
+                        xtype: 'textfield',
+                        name: 'ort_longitude',
+                        fieldLabel: 'Lon'
+                    },
+                    {
+                        xtype: 'textfield',
+                        name: 'ort_hoeheLand',
+                        fieldLabel: 'Höhe'
+                    }
+                ]
+            }
         ];
         this.callParent();
+    },
+    updateOrtInfo: function(field, oldv, newv, opts) {
+        console.log(field, oldv, newv, opts);
     }
 });
--- a/app/view/orte/List.js	Mon Jul 01 14:20:08 2013 +0200
+++ b/app/view/orte/List.js	Mon Jul 01 17:05:03 2013 +0200
@@ -10,6 +10,7 @@
         minHeight: 35,
         deferEmptyText: false
     },
+    probeId: null,
     initComponent: function() {
         this.dockedItems = [
             {
@@ -19,7 +20,8 @@
                     {
                         text: 'Hinzufügen',
                         icon: 'gfx/plus.gif',
-                        action: 'add'
+                        action: 'add',
+                        probeId: this.probeId
                     },
                     {
                         text: 'Löschen',
@@ -30,12 +32,50 @@
             }
         ];
         this.columns = [
-            {header: 'Typ', dataIndex: 'otyp'},
-            {header: 'ID', dataIndex: 'ortId'},
-            {header: 'Staat', dataIndex: 'staatId'},
-            {header: 'Gem-ID', dataIndex: 'gemId'},
-            {header: 'Gemeindebezeichnung', dataIndex: 'bezeichnung', flex: 1},
-            {header: 'Messpunkt', dataIndex: ''}
+            {
+                header: 'Typ',
+                dataIndex: 'ortsTyp'
+            },
+            {
+                header: 'Staat',
+                dataIndex: 'ortId',
+                renderer: function(value) {
+                    var store = Ext.getStore('Ortedetails');
+                    var staaten = Ext.getStore('Staaten');
+                    var record = staaten.getById(store.getById(value).get('staatId'));
+                    return record.get('staatIso');
+                }
+
+            },
+            {
+                header: 'Gem-ID',
+                dataIndex: 'ortId',
+                renderer: function(value) {
+                    var store = Ext.getStore('Ortedetails');
+                    var record = store.getById(value);
+                    return record.get('gemId');
+                }
+
+            },
+            {
+                header: 'Gemeindebezeichnung',
+                dataIndex: 'ortId',
+                flex: 1,
+                renderer: function(value) {
+                    var store = Ext.getStore('Ortedetails');
+                    var record = store.getById(value);
+                    return record.get('beschreibung');
+                }
+
+            },
+            {
+                header: 'Messpunkt',
+                dataIndex: 'ortId',
+                renderer: function(value) {
+                    return "???";
+                }
+
+            }
         ];
         this.callParent(arguments);
     }

http://lada.wald.intevation.org