changeset 1265:a4c1a9862a88

merged
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 14 Dec 2016 10:21:48 +0100
parents 3d83bcb02ee3 (diff) 26197c2d9362 (current diff)
children c4059495a346 a792eecf1614
files
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/view/grid/Ortszuordnung.js	Thu Dec 08 15:56:41 2016 +0100
+++ b/app/view/grid/Ortszuordnung.js	Wed Dec 14 10:21:48 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