changeset 1288:08085b7d1d0b

Ortszuordnung: Search, new orte, display and validity check
author Maximilian Krambach <mkrambach@intevation.de>
date Fri, 27 Jan 2017 13:25:14 +0100
parents e317ba349204
children bfdc00c24baf
files app/controller/form/Ortszuordnung.js app/controller/grid/Ortszuordnung.js app/view/form/OrtInfo.js app/view/form/Ortserstellung.js app/view/form/Ortszuordnung.js app/view/panel/Map.js app/view/window/MessprogrammOrt.js app/view/window/Ortszuordnung.js
diffstat 8 files changed, 293 insertions(+), 267 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/form/Ortszuordnung.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/controller/form/Ortszuordnung.js	Fri Jan 27 13:25:14 2017 +0100
@@ -27,7 +27,8 @@
                 click: this.discard
             },
             'ortszuordnungform': {
-                dirtychange: this.dirtyForm
+                validitychange: this.validityChange,
+                dirtychange: this.validityChange
             }
         });
     },
@@ -84,7 +85,9 @@
                 formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
                 var json = response.request.scope.reader.jsonData;
                 if (json) {
-                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                    if(Object.keys(json.errors).length > 0 ||
+                        Object.keys(json.warnings).length > 0) {
+
                         formPanel.setMessages(json.errors, json.warnings);
                     }
 
@@ -118,65 +121,53 @@
         }
         catch (e) {
         }
-        //set undirty.
-        formPanel.fireEvent('dirtychange', formPanel.getForm(), false);
     },
 
     /**
      * When the button is Active, a Record can be selected.
      * If the Record was selected from a grid this function
-     *  sets the ortzuordnung.
+     * sets the ortzuordnung.
      * TODO: Check if the selected Record is a ORT
-     * TODO: Enable picking from Maps
      */
-     pickOrt: function(button, pressed, opts) {
+    chooseLocation: function(button, pressed, opts) {
         var i18n = Lada.getApplication().bundle;
-        var oForm = button.up('form');
-        var osg = button.up('window').down('ortstammdatengrid');
-        if (button.pressed) {
-            button.setText(i18n.getMsg('ortszuordnung.form.setOrt.pressed'));
-            osg.addListener('select',oForm.setOrt, oForm);
-        }
-        else {
-            button.setText(i18n.getMsg('ortszuordnung.form.setOrt'));
-            osg.removeListener('select',oForm.setOrt, oForm);
-        }
-     },
-
-    chooseLocation: function(button, pressed, opts) {
         var win = button.up('window');
         var gridPanel = win.down('panel[name=ortgrid]');
+        var osg = win.down('ortstammdatengrid');
+        var oForm = button.up('form');
         if (pressed) {
             win.setHeight(Ext.getBody().getViewSize().height - 50);
+            button.setText(i18n.getMsg('ortszuordnung.form.setOrt.pressed'));
             win.setY(25);
             gridPanel.show();
+            osg.addListener('select',oForm.setOrt, oForm);
+
         }
         else {
             var y = (Ext.getBody().getViewSize().height - 465) / 2
             win.setHeight(465);
             win.setY(y);
+            button.setText(i18n.getMsg('ortszuordnung.form.setOrt'));
             gridPanel.hide();
+            osg.removeListener('select',oForm.setOrt, oForm);
         }
     },
 
-
     /**
-     * The dirtyForm function enables or disables the save and discard
+     * The validitychange function enables or disables the save and discard
      * button which are present in the toolbar of the form.
-     * The Buttons are only active if the content of the form was altered
-     * (the form is dirty).
      */
-    dirtyForm: function(form, dirty) {
-        if (dirty) {
-            if (form.getValues().ortId !== ''
+    validityChange: function(form, valid) {
+        if (form.isDirty()) {
+            form.owner.down('button[action=discard]').setDisabled(false);
+            if ( valid && form.getValues().ortId !== ''
                 && /[UEZA]/.test(form.getValues().ortszuordnungTyp)
-               ) {
+            ) {
                 form.owner.down('button[action=save]').setDisabled(false);
+            } else {
+                form.owner.down('button[action=save]').setDisabled(true);
             }
-            form.owner.down('button[action=discard]').setDisabled(false);
-        }
-        else {
-            form.owner.down('button[action=save]').setDisabled(true);
+        } else {
             form.owner.down('button[action=discard]').setDisabled(true);
         }
     }
--- a/app/controller/grid/Ortszuordnung.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/controller/grid/Ortszuordnung.js	Fri Jan 27 13:25:14 2017 +0100
@@ -14,7 +14,7 @@
 
     requires: [
         'Lada.view.window.Ortszuordnung',
-        'Lada.view.form.Ortserstellung',
+        'Lada.view.window.Ortserstellung',
         'Lada.view.window.OrtFilter'
     ],
 
@@ -134,26 +134,22 @@
     /**
      * Opens the form for a new Messpunkt
      */
-    createort: function() {
-        Ext.create('Lada.view.form.Ortserstellung').show();
+    createort: function(button) {
+        Ext.create('Lada.view.window.Ortserstellung',{
+            parentWindow: button.up('ortszuordnungwindow')
+        }).show();
     },
 
     /**
      *
-     * Opens the form for a new Messpunkt, with prefilled coordinates.
-     * TODO Not functional yet
+     * Creates an event listener for a map click
      */
     frommap: function(button) {
         var map = button.up('ortszuordnungwindow').down('map');
-        // map.getClick();
-        //TODO: wait for click return
-        Ext.create('Lada.view.form.Ortserstellung', {
-            presets: {
-                kda_id: 4,
-                koord_x_extern: 35000000, //TODO dummy values
-                koord_y_extern: 1000000
-            }
-        }).show();
+        var me = this;
+        map.map.events.register('click', button, me.newOrtfromMapClick);
+        // TODO visual feedback that map click is active.
+        // TODO Deactivate event listener if button is destroyed
     },
 
     /**
@@ -163,8 +159,29 @@
     cloneort: function(button) {
         var grid = button.up('ortszuordnungwindow').down('ortstammdatengrid').getView();
         var selected = grid.getSelectionModel().getSelection()[0];
-         Ext.create('Lada.view.form.Ortserstellung', {
-             presets: selected.data
+         Ext.create('Lada.view.window.Ortserstellung', {
+             record: Ext.create('Lada.model.Ort', selected.data),
+             parentWindow: button.up('ortszuordnungwindow')
+        }).show();
+    },
+
+    /**
+     * Gets the clicked map's coordinates and opens a new Messpunkt window with coordinates prefilled
+     */
+    newOrtfromMapClick: function(evt) {
+        var me = this; //this = button(action:frommap)
+        var map = this.up('ortszuordnungwindow').down('map').map;
+        var lonlat = map.getLonLatFromViewPortPx(evt.xy).transform(new OpenLayers.Projection('EPSG:3857'),
+                                                                   new OpenLayers.Projection('EPSG:4326'));
+        var controller = Lada.app.getController('Lada.controller.grid.Ortszuordnung');
+        map.events.unregister('click', this, controller.newOrtfromMapClick);
+        Ext.create('Lada.view.window.Ortserstellung', {
+            record: Ext.create('Lada.model.Ort',{
+                koordXExtern: lonlat.lon,
+                koordYExtern: lonlat.lat,
+                kdaId : 4
+            }),
+            parentWindow: this.up('ortszuordnungwindow')
         }).show();
     },
 
@@ -239,20 +256,26 @@
         var grid = this.searchField.up('panel').down('ortstammdatengrid');
         grid.getSelectionModel().select(record);
         grid.getView().focusRow(record);
-        console.log(record);
     },
 
     selectedVerwaltungseinheit: function(grid, record) {
         var win = grid.up('window');
         win.hide();
         this.searchField.reset();
-        console.log(record);
+        Ext.create('Lada.view.window.Ortserstellung', {
+            record: Ext.create('Lada.model.Ort', record.data),
+            parentWindow: grid.up('ortszuordnungwindow')
+        }).show();
     },
 
     selectedStaat: function(grid, record) {
         var win = grid.up('window');
+        console.log(grid.up('ortszuordnungwindow'));
         win.hide();
+        Ext.create('Lada.view.window.Ortserstellung', {
+            record: Ext.create('Lada.model.Ort', record.data),
+            parentWindow: grid.up('ortszuordnungwindow')
+        }).show();
         this.searchField.reset();
-        console.log(record);
     }
 });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/form/OrtInfo.js	Fri Jan 27 13:25:14 2017 +0100
@@ -0,0 +1,76 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Form used to display the data of an Ort record.
+ */
+Ext.define('Lada.view.form.OrtInfo', {
+    extend: 'Ext.form.Panel',
+    alias: 'widget.ortinfo',
+    model: 'Lada.model.Ort',
+    border: 0,
+    flex: 1,
+    margin: '0, 10, 0, 0',
+    record: null,
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+        this.items = [{
+            layout: 'vbox',
+            flex: 1,
+            border: 0,
+            items: [{
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.ortId'),
+                name: 'ortId'
+            },
+            {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.kurztext'),
+                name: 'kurztext'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.langtext'),
+                name: 'langtext'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('staat'),
+                name: 'staatISO'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.gemeinde'),
+                name: 'gemeinde'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.gemeindename'),
+                name: 'gemeinde'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.kda'),
+                name: 'kdaId'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.koordx'),
+                name: 'koordXExtern'
+            }, {
+                xtype: 'displayfield',
+                labelWidth: 125,
+                fieldLabel: i18n.getMsg('orte.koordy'),
+                name: 'koordYExtern'
+            }]
+        }];
+        this.callParent(arguments);
+    }
+});
\ No newline at end of file
--- a/app/view/form/Ortserstellung.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/view/form/Ortserstellung.js	Fri Jan 27 13:25:14 2017 +0100
@@ -8,7 +8,6 @@
 
 /**
  * Form to create a new Messpunkt
- * TODO: layout
  */
 Ext.define('Lada.view.form.Ortserstellung', {
     extend: 'Ext.form.Panel',
@@ -33,7 +32,7 @@
             margin : '0, 5, 5, 5',
             labelWidth: 80,
             width: 150,
-            value: Lada.netzbetreiber
+            value: Lada.netzbetreiber[0]
             }, {
             xtype: 'checkbox',
             name: 'aktiv',
@@ -238,10 +237,8 @@
         this_panel.record.set('id', null);
         this_panel.record.set('ortId', null);
         this_panel.record.set('netzbetreiberId', Lada.netzbetreiber[0]);
-        console.log(this_panel.record);
         this_panel.record.save({
             success: function(record, response) {
-                console.log(response);
                 var newOrtId;
                 Ext.Msg.show({
                     title: Lada.getApplication().bundle.getMsg('success'),
@@ -265,28 +262,24 @@
                 });
             },
             failure: function(record, response) {
-                console.log(response);
-                // TODO
-//                 response.error.status
-//                 response.error.statusText
-//                 var json = Ext.decode(response.response.responseText);
-//                 if (json) {
-//                     if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
-//                         console.log(json.errors);
-//                         console.log(json.warnings);
-//                         formPanel.setMessages(json.errors, json.warnings);
-//                     }
-//                     if(json.message){
-//                         Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
-//                             +' #'+json.message,
-//                             Lada.getApplication().bundle.getMsg(json.message));
-//                     } else {
-//                          Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
-//                             Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
-//                     }
-//                 } else {
-//                     Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
-//                         Lada.getApplication().bundle.getMsg('err.msg.response.body'));
+                // TODO check
+                var json = Ext.decode(response.response.responseText);
+                if (json) {
+                    if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                        formPanel.setMessages(json.errors, json.warnings);
+                    }
+                    if(json.message){
+                        Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
+                            +' #'+json.message,
+                             Lada.getApplication().bundle.getMsg(json.message));
+                    } else {
+                         Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
+                             Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
+                    }
+                } else {
+                    Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
+                        Lada.getApplication().bundle.getMsg('err.msg.response.body'));
+                }
             }
         });
     }
--- a/app/view/form/Ortszuordnung.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/view/form/Ortszuordnung.js	Fri Jan 27 13:25:14 2017 +0100
@@ -16,6 +16,7 @@
     model: 'Lada.model.Ortszuordnung',
 
     requires: [
+        'Lada.view.form.OrtInfo',
         'Lada.view.widget.Verwaltungseinheit',
         'Lada.view.widget.Staat'
     ],
@@ -30,6 +31,7 @@
 
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
+        var me = this;
         this.items = [{
             xtype: 'fieldset',
             title: i18n.getMsg('ortszuordnung.form.fset.title'),
@@ -75,7 +77,7 @@
                     items: [{
                         layout: 'vbox',
                         border: 0,
-                        margin: '0, 10, 0, 0',
+                        margin: '0, 20, 0, 0',
                         items: [{
                             xtype: 'tfield',
                             labelWidth: 125,
@@ -87,82 +89,39 @@
                             labelWidth: 125,
                             maxLength: 1,
                             allowBlank: false,
-                            regex: /[UEZA]/,
+                            regex: /[UEZA]{1}/,
                             activeError: 'U, E, Z oder A eingeben',
                             name: 'ortszuordnungTyp',
-                            fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp')
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.ortid'),
-                            submitValue: true,
-                            name: 'ortId'
-                        }]
-                    }, {
-                        layout: 'vbox',
-                        flex: 1,
-                        margin: '0, 10, 0, 0',
-                        border: 0,
-                        items: [{
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.kurztext'),
-                            name: 'kurztext'
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.langtext'),
-                            name: 'langtext'
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('staat'),
-                            name: 'staatISO'
+                            fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp'),
+
                         }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.gemeinde'),
-                            name: 'gemeinde'
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.gemeindename'),
-                            name: 'gemeinde'
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.kda'),
-                            name: 'kdaId'
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.koordx'),
-                            name: 'koordXExtern'
-                        }, {
-                            xtype: 'displayfield',
-                            labelWidth: 125,
-                            fieldLabel: i18n.getMsg('orte.koordy'),
-                            name: 'koordYExtern'
+                            // this field is hidden because the user doesn't
+                            // need to know the internal ortID
+                            xtype: 'textfield',
+                            // fieldLabel: i18n.getMsg('orte.ortid'),
+                            allowBlank: false,
+                            regex: /^[0-9]{1,45}$/,
+                            submitValue: true,
+                            hidden: true,
+                            name: 'ortId',
+                            listeners: {
+                                change: me.changedOrt
+                            }
                         }]
-                    }]
+                    },
+                    Ext.create('Lada.view.form.OrtInfo', {
+                            record: me.record
+                    })
+                    ]
                 }]
-                //}, {
-                //    layout: 'vbox',
-                //    flex: 1,
-                //    margin: '0, 10, 0, 0',
-                //    border: 0,
-                //    items: [{
-                //        xtype: ''
-                //    }]
-                }]
-            }];
+            }]
+        }];
         this.callParent(arguments);
     },
 
     setRecord: function(record) {
         this.getForm().loadRecord(record);
-
-        if (! record.get('readonly')) {
+        if (!record.get('readonly')) {
             this.down('[action=setOrt]').enable();
             this.setReadOnly(false);
         }
@@ -183,8 +142,9 @@
         var verw = verwStore.getById(ort.get('gemId'));
         var staatStore = Ext.StoreManager.get('staaten');
         var staat = staatStore.getById(ort.get('staatId'));
-
-        this.getForm().setValues({
+        var ortinfo = this.down('ortinfo')
+        ortinfo.loadRecord(ort);
+        ortinfo.getForm().setValues({
             gemeinde: verw.get('bezeichnung'),
             staat: staat.get('staatIso'),
             lon: ort.get('longitude'),
@@ -194,7 +154,7 @@
 
     /**
      * setOrt can be called from a CallbackFunction, ie select from a grid.
-     *  it will set the ortId of this record
+     * it will set the ortId of this record
      */
     setOrt: function(row, selRecord, index, opts) {
         var newOrtId = selRecord.get('id');
@@ -204,8 +164,6 @@
                 r.set('ortId', newOrtId);
                 this.getForm().setValues({ortId: newOrtId});
                 this.refreshOrt(newOrtId);
-                //set dirty...
-                this.fireEvent('dirtychange', this.getForm(), true);
             }
         }
     },
@@ -240,7 +198,7 @@
                 for (var i = 0; i < content.length; i++) {
                     errorText += i18n.getMsg(content[i].toString()) + '\n';
                 }
-                element.showErrors(errorText);
+                element.markInvalid(errorText);
             }
         }
      },
@@ -252,6 +210,17 @@
     setReadOnly: function(value) {
         this.down('tfield[name=ortszusatztext]').setReadOnly(value);
         this.down('textfield[name=ortszuordnungTyp]').setReadOnly(value);
+    },
+
+    /**
+     * Helper to trigger the forms' validity check on change of ortID
+     */
+    changedOrt: function() {
+        var controller = Lada.app.getController(
+            'Lada.controller.form.Ortszuordnung');
+        var form = this.up('form').getForm();
+        controller.validityChange(form, form.isValid());
+
     }
 });
 
--- a/app/view/panel/Map.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/view/panel/Map.js	Fri Jan 27 13:25:14 2017 +0100
@@ -63,10 +63,10 @@
             zoomMethod: null,
             // initializing with view centered on germany
             center: new OpenLayers.LonLat(1160000,6694000),
-            zoom: 7
         });
         this.map.setOptions(this.mapOptions);
         this.map.addLayers(this.layers);
+        this.map.zoomTo(6);
         var keyControl = new OpenLayers.Control.KeyboardDefaults();
         this.map.addControl(keyControl);
         keyControl.activate();
--- a/app/view/window/MessprogrammOrt.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/view/window/MessprogrammOrt.js	Fri Jan 27 13:25:14 2017 +0100
@@ -9,25 +9,29 @@
 /**
  * Window to add a Ort to a Messprogramm
  */
+// TODO: This is >80% identical to Lada.view.form.Ortszuordnung.
+// Differences: This has no ortszuordnung record. It only receives and sends
+// an ortId
+
 Ext.define('Lada.view.window.MessprogrammOrt', {
     extend: 'Ext.window.Window',
     alias: 'widget.messprogrammort',
 
     requires: [
-        'Lada.model.Ort',
+        'Lada.view.form.Ortserstellung',
         'Lada.view.panel.Map',
-        'Lada.view.widget.Location',
-        'Lada.view.form.Location'
+        'Lada.view.grid.Orte'
     ],
 
     collapsible: true,
     maximizable: true,
     autoshow: true,
-    layout: 'border',
+    layout: 'fit',
     constrain: true,
 
     parentWindow: null,
-    record: null,
+
+    ortId: null,
 
     /**
      * This function initialises the Window
@@ -49,9 +53,6 @@
                     .ortWindow = null;
            }
         }];
-        this.width = 900;
-        this.height = 515;
-        this.bodyStyle = {background: '#fff'};
 
         // add listeners to change the window appearence when it becomes inactive
         this.on({
@@ -68,120 +69,94 @@
         });
 
         this.items = [{
-            region: 'west',
+            layout: 'border',
+            bodyStyle: {background: '#fff'},
             border: 0,
-            layout: 'vbox',
-            items: [{
-                xtype: 'fieldset',
-                title: i18n.getMsg('ortId'),
-                margin: 5,
-                items: [{
-                    border: 0,
-                    margin: '0, 0, 10, 0',
-                    items: [{
-                        xtype: 'location',
-                        fieldLabel: i18n.getMsg('ortId'),
-                        labelWidth: 80,
-                        width: 280,
-                        forceSelection: true,
-                        name: 'ortId',
-                        listeners: {//Update MapPanel etc...
-                            select: this.updateDetails
-                        }
-                    }]
-                }]
-            }, {
-                xtype: 'locationform',
-                margin: 5,
-                recordId: this.record.get('ortId')
-            }]
-        }, {
-            xtype: 'fset',
-            bodyStyle: {
-                background: '#fff'
-            },
-            layout: 'border',
-            name: 'mapfield',
-            title: 'Karte',
-            region: 'center',
-            padding: '5, 5',
-            margin: 5,
             items: [{
                 xtype: 'map',
                 region: 'center',
                 layout: 'border',
-                record: this.record.get('ortId') ? this.record : null,
-                bodyStyle: {
-                    background: '#fff'
-                },
-                name: 'map',
-                listeners: { //A listener which listens to the mappanels featureselected event
-                    featureselected: this.selectedFeature
-                }
+                margin: '13, 5, 10, 5',
+                minHeight: 380,
+                externalOrteStore: true
+            }, {
+                xtype: 'panel',
+                layout: 'hbox',
+                border: 0,
+                margin: '0, 0, 10, 0',
+                dockedItems: [{
+                    xtype: 'toolbar',
+                    dock: 'bottom',
+                    border: '0, 1, 1, 1',
+                    style: {
+                        borderBottom: '1px solid #b5b8c8 !important',
+                        borderLeft: '1px solid #b5b8c8 !important',
+                        borderRight: '1px solid #b5b8c8 !important'
+                    },
+                    items: [{
+                        text: i18n.getMsg('ortszuordnung.form.setOrt'),
+                        tooltip: i18n.getMsg('ortszuordnung.form.setOrt.qtip'),
+                        icon: 'resources/img/dialog-ok-apply.png',
+                        action: 'setOrt',
+                        enableToggle: true,
+                        disabled: true
+                    }, '->', {
+                        text: i18n.getMsg('save'),
+                        tooltip: i18n.getMsg('save.qtip'),
+                        icon: 'resources/img/dialog-ok-apply.png',
+                        action: 'save',
+                        disabled: true
+                    }, {
+                        text: i18n.getMsg('discard'),
+                        tooltip: i18n.getMsg('discard.qtip'),
+                        icon: 'resources/img/dialog-cancel.png',
+                        action: 'discard',
+                        disabled: true
+                    }]
+                }],
+                items: [Ext.create('Lada.view.form.OrtInfo')]
+            }, {
+                region: 'south',
+                border: 0,
+                layout: 'fit',
+                name: 'ortgrid',
+                hidden: true,
+                maxHeight: 240,
+                items: [{
+                    xtype: 'ortstammdatengrid'
+                }],
+                dockedItems: [{
+                    xtype: 'toolbar',
+                    dock: 'bottom',
+                    border: '0, 1, 1, 1',
+                    style: {
+                        borderBottom: '1px solid #b5b8c8 !important',
+                        borderLeft: '1px solid #b5b8c8 !important',
+                        borderRight: '1px solid #b5b8c8 !important'
+                    },
+                    items: [{
+                        xtype: 'textfield',
+                        name: 'search',
+                        labelWidth: 50,
+                        enableKeyEvents: true,
+                        fieldLabel: i18n.getMsg('ortszuordnung.ortsuche'),
+                    }, '->', {
+                        text: i18n.getMsg('orte.new'),
+                        action: 'createort'
+                    }, {
+                        text: i18n.getMsg('orte.frommap'),
+                        action: 'frommap'
+                    }, {
+                        text: i18n.getMsg('orte.clone'),
+                        action: 'clone'
+                    }]
+                }]
             }]
         }];
         this.callParent(arguments);
+        //TODO: load the passed OrtId
     },
 
-    /**
-     * Initialise the Data of this Window.
-     */
-    initData: function() {
-        //Only do this if an OrtId exists...
-        var ortId = this.record.get('ortId');
-
-        if (ortId) {
-            Ext.ClassManager.get('Lada.model.Ort').load(ortId, {
-                failure: function(record, action) {
-                    // TODO
-                },
-                success: function(record, response) {
-                    var me = this;
-                    if (record.get('treeModified') < record.get('parentModified')) {
-                        Ext.Msg.show({
-                            title: 'Messprogramm nicht aktuell!',
-                            msg: 'Das zugehörige Messprogramm wurde verändert.\nMöchten Sie zu dem Messprogramm zurückkehren und neu laden?\nOhne das erneute Laden des Messprogrammes wird das Speichern des Ortes nicht möglich sein.',
-                            buttons: Ext.Msg.OKCANCEL,
-                            icon: Ext.Msg.WARNING,
-                            closable: false,
-                            fn: function(button) {
-                                if (button === 'ok') {
-                                    me.close();
-                                    me.parentWindow.initData();
-                                    me.parentWindow.down('messprogrammform')
-                                        .ortWindow = null;
-                                }
-                                else {
-                                    me.record.set('treeModified', me.probe.get('treeModified'));
-                                }
-                            }
-                        });
-                    }
-                    this.record = record;
-                },
-                scope: this
-            });
-        }
-    },
-
-    /**
-     * @private
-     * Override to display and update the map view in the panel.
-     */
-    afterRender: function(){
-        this.superclass.afterRender.apply(this, arguments);
-        var map = this.down('map');
-        if (this.record.get('ortId')) {
-            map.selectFeature(this.record.get('ortId'));
-        }
-        else {
-            map.map.zoomToMaxExtent();
-        }
-    },
-
-    /**
-     * This function is used by the MapPanel, when a Feature was selected
-     */
     selectedFeature: function(context, args) {
     var feature = args[0];
         if (feature.attributes.id &&
--- a/app/view/window/Ortszuordnung.js	Thu Jan 26 17:33:56 2017 +0100
+++ b/app/view/window/Ortszuordnung.js	Fri Jan 27 13:25:14 2017 +0100
@@ -16,7 +16,8 @@
     requires: [
         'Lada.view.form.Ortszuordnung',
         'Lada.view.form.Ortserstellung',
-        'Lada.view.panel.Ort'
+        'Lada.view.panel.Map',
+        'Lada.view.grid.Orte'
     ],
 
     collapsible: true,
@@ -26,6 +27,7 @@
     constrain: true,
 
     probe: null,
+
     parentWindow: null,
     record: null,
     grid: null,
@@ -35,7 +37,6 @@
      */
     initComponent: function() {
         var i18n = Lada.getApplication().bundle;
-
         this.title = i18n.getMsg('ortszuordnung.window.title');
 
         if (this.record && this.probe) {
@@ -62,7 +63,6 @@
                             + ' '
                             + i18n.getMsg('create');
         }
-
         this.buttons = [{
             text: i18n.getMsg('close'),
             scope: this,
@@ -82,7 +82,6 @@
             }
         });
 
-
         this.items = [{
             layout: 'border',
             bodyStyle: {background: '#fff'},

http://lada.wald.intevation.org