changeset 1264:3d83bcb02ee3

Load unknown ort and refresh ortzuordnungs grid.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 14 Dec 2016 10:20:52 +0100
parents 96f9417c105e
children a4c1a9862a88
files app/view/grid/Ortszuordnung.js
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/view/grid/Ortszuordnung.js	Mon Nov 28 08:28:53 2016 +0100
+++ b/app/view/grid/Ortszuordnung.js	Wed Dec 14 10:20:52 2016 +0100
@@ -31,6 +31,7 @@
     allowDeselect: true,
 
     initComponent: function() {
+        var me = this;
         this.dockedItems = [{
             xtype: 'toolbar',
             dock: 'bottom',
@@ -75,6 +76,21 @@
             renderer: function(value) {
                 var store = Ext.data.StoreManager.get('orte');
                 var record = store.getById(value);
+                if (!record) {
+                    record = Ext.create('Lada.model.Ort');
+                    record.set('id', value);
+                    store.add(record);
+                    Lada.model.Ort.load(value, {
+                        success: function(rec) {
+                            record.beginEdit();
+                            for (key in rec.getData()) {
+                                record.set(key, rec.getData()[key]);
+                            }
+                            record.endEdit();
+                            me.getView().refresh();
+                        }
+                    });
+                }
                 return record.get('ortId');
             }
         }, {
@@ -84,8 +100,11 @@
             renderer: function(value) {
                 var store = Ext.data.StoreManager.get('orte');
                 var staaten = Ext.data.StoreManager.get('staaten');
-                var record =
-                    staaten.getById(store.getById(value).get('staatId'));
+                var ortRecord = store.getById(value);
+                if (!ortRecord || ortRecord.get('staatId') === '') {
+                    return '';
+                }
+                var record = staaten.getById(ortRecord.get('staatId'));
                 return record.get('staatIso');
             }
         }, {
@@ -95,6 +114,9 @@
             renderer: function(value) {
                 var store = Ext.data.StoreManager.get('orte');
                 var record = store.getById(value);
+                if (!record || record.get('gemId') === '') {
+                    return '';
+                }
                 return record.get('gemId');
             }
         }, {
@@ -106,6 +128,9 @@
                 var gemeinden =
                     Ext.data.StoreManager.get('verwaltungseinheiten');
                 var record = store.getById(value);
+                if (!record || record.get('gemId') === '') {
+                    return '';
+                }
                 var gemid = record.get('gemId');
                 var record2 = gemeinden.getById(gemid);
                 return record2.get('bezeichnung');
@@ -117,6 +142,9 @@
             renderer: function(value) {
                 var store = Ext.data.StoreManager.get('orte');
                 var record = store.getById(value);
+                if (!record || record.get('anlageId') === '') {
+                    return '';
+                }
                 return record.get('anlageId');
             }
         }];

http://lada.wald.intevation.org