changeset 1309:1bcc3a62e909

insert and preset OrtId field on Orterstellung
author Maximilian Krambach <mkrambach@intevation.de>
date Thu, 02 Feb 2017 16:59:25 +0100
parents 6075731bc4f1
children 9b50bf4c218b
files app/controller/grid/Ortszuordnung.js app/model/Ort.js app/view/form/Ortserstellung.js
diffstat 3 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/grid/Ortszuordnung.js	Thu Feb 02 16:43:53 2017 +0100
+++ b/app/controller/grid/Ortszuordnung.js	Thu Feb 02 16:59:25 2017 +0100
@@ -171,8 +171,10 @@
     cloneort: function(button) {
         var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
         var selected = grid.getSelectionModel().getSelection()[0];
-         Ext.create('Lada.view.window.Ortserstellung', {
-             record: Ext.create('Lada.model.Ort', selected.data),
+        var newRecord = Ext.create('Lada.model.Ort', selected.data);
+        newRecord.set('ortId', '');
+        Ext.create('Lada.view.window.Ortserstellung', {
+             record: newRecord,
              parentWindow: button.up('ortszuordnungwindow')
         }).show();
     },
@@ -252,7 +254,8 @@
                     item.get('berichtstext').indexOf(filter) > -1) {
                     return true;
                 }
-                if (item.get('gemId').indexOf(filter) > -1) {
+                if (item.get('gemId') &&
+                    item.get('gemId').indexOf(filter) > -1) {
                     return true;
                 }
             }});
@@ -289,7 +292,11 @@
         this.searchField.reset();
         Ext.create('Lada.view.window.Ortserstellung', {
             record: Ext.create('Lada.model.Ort', {
-                gemId: record.get('id')
+                gemId: record.get('id'),
+                ortId: record.get('id'),
+                kurztext: record.get('bezeichnung'),
+                langtext: record.get('bezeichnung'),
+                berichtstext: record.get('bezeichnung')
             }),
             parentWindow: panel
         }).show();
@@ -301,7 +308,11 @@
         this.searchField.reset();
         Ext.create('Lada.view.window.Ortserstellung', {
             record: Ext.create('Lada.model.Ort', {
-                staatId: record.get('id')
+                staatId: record.get('id'),
+                ortId: 'Staat_' + record.get('staatIso'),
+                kurztext: record.get('staat'),
+                langtext: record.get('staat'),
+                berichtstext: record.get('staat')
             }),
             parentWindow: win
         }).show();
--- a/app/model/Ort.js	Thu Feb 02 16:43:53 2017 +0100
+++ b/app/model/Ort.js	Thu Feb 02 16:59:25 2017 +0100
@@ -17,7 +17,13 @@
     }, {
         name: 'aktiv'
     }, {
-        name: 'ortId'
+        name: 'ortId',
+        convert: function(v) {
+            if (v === '') {
+                return null;
+            }
+            return v;
+        }
     }, {
         name: 'nutsCode'
     }, {
--- a/app/view/form/Ortserstellung.js	Thu Feb 02 16:43:53 2017 +0100
+++ b/app/view/form/Ortserstellung.js	Thu Feb 02 16:59:25 2017 +0100
@@ -35,6 +35,12 @@
             labelWidth: 125,
             value: Lada.netzbetreiber[0]
         }, {
+            xtype: 'textfield',
+            name: 'ortId',
+            maxLength: 10,
+            labelWidth: 125,
+            fieldLabel: i18n.getMsg('orte.ortId')
+        }, {
             xtype: 'checkbox',
             name: 'aktiv',
             fieldLabel: 'aktiv:'
@@ -265,7 +271,6 @@
         }
         this_panel.record.set('letzteAenderung', 0);
         this_panel.record.set('id', null);
-        this_panel.record.set('ortId', null);
         this_panel.record.set('netzbetreiberId', Lada.netzbetreiber[0]);
         this_panel.record.save({
             success: function(record, response) {

http://lada.wald.intevation.org