[Lada-commits] [PATCH] Added Orte

Wald Commits scm-commit at wald.intevation.org
Mon Jul 1 17:05:55 CEST 2013


# HG changeset patch
# User Torsten Irländer <torsten.irlaender at intevation.de>
# Date 1372691103 -7200
# Node ID 26ac4c99f8c4030a279a394dab9c73b85dfa35f8
# Parent  ed7fb4fa32dcb3288185035c48b8bae08b92495a
Added Orte.

diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app.js
--- 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'
     ]
 });
diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app/controller/Orte.js
--- 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');
diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app/controller/Proben.js
--- 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) {
diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app/model/Ort.js
--- 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
diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app/view/orte/Create.js
--- 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();
diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app/view/orte/CreateForm.js
--- 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);
     }
 });
diff -r ed7fb4fa32dc -r 26ac4c99f8c4 app/view/orte/List.js
--- 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);
     }


More information about the Lada-commits mailing list