diff app/view/panel/Ort.js @ 1051:981339d774b8

merged stammdatengrids to default.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 01 Mar 2016 14:12:39 +0100
parents e0b5e64928c9
children 291df0037835
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/panel/Ort.js	Tue Mar 01 14:12:39 2016 +0100
@@ -0,0 +1,147 @@
+Ext.define('Lada.view.panel.Ort', {
+    extend: 'Ext.panel.Panel',
+    alias: 'widget.ortpanel',
+
+    requires: [
+        'Lada.view.panel.Map',
+        'Lada.view.grid.Orte'
+    ],
+
+    width: '100%',
+    //height: 200,
+
+    layout: {
+        type: 'border'
+    },
+    toolbarPos: 'top',
+
+    editableGrid: true,
+
+    initComponent: function() {
+        var i18n = Lada.getApplication().bundle;
+
+        // Different Layout of toolbar depending on the bars position.
+        if (this.toolbarPos == 'top') {
+            this.dockedItems = [{
+                xtype: 'toolbar',
+                dock: 'top',
+                items: [{
+                    xtype: 'tbtext',
+                    text: i18n.getMsg('orte.gridTitle')
+                },
+                '->',
+                {
+                    text: i18n.getMsg('map.button.add'),
+                    icon: 'resources/img/list-add.png',
+                    action: 'addMap',
+                    disabled: true // disabled on startup, will be enabled by setStore
+                }, {
+                    text: i18n.getMsg('orte.button.add'),
+                    icon: 'resources/img/list-add.png',
+                    action: 'add',
+                    disabled: true // disabled on startup, will be enabled by setStore
+                }, {
+                    text: i18n.getMsg('orte.button.delete'),
+                    icon: 'resources/img/list-remove.png',
+                    action: 'delete',
+                    disabled: true // disabled on startup, will be enabled by controller if necessary
+                }]
+            }];
+        }
+        else {
+            this.dockedItems = [{
+                xtype: 'toolbar',
+                dock: this.toolbarPos,
+                items: [ '->',
+                {
+                    text: i18n.getMsg('map.button.add'),
+                    icon: 'resources/img/list-add.png',
+                    action: 'addMap',
+                    disabled: true // disabled on startup, will be enabled by setStore
+                }, {
+                    text: i18n.getMsg('orte.button.add'),
+                    icon: 'resources/img/list-add.png',
+                    action: 'add',
+                    disabled: true // disabled on startup, will be enabled by setStore
+                }]
+            }];
+        }
+
+        this.items = [{
+            xtype: 'ortstammdatengrid',
+            width: '60%',
+            editableGrid: this.editableGrid,
+            collapsible: true,
+            region: 'east'
+        }, {
+            xtype: 'map',
+            region: 'center',
+            layout: 'border',
+            title: i18n.getMsg('map.title'),
+            externalOrteStore: true,
+            listeners: {
+                beforecollapse: function() {
+                    var c = this.map.getControlsByClass('OpenLayers.Control.ScaleLine');
+                    this.map.removeControl(c[0]);
+                },
+                expand: function() {
+                    this.map.addControl(new OpenLayers.Control.ScaleLine());
+                }
+            }
+        }];
+
+        this.callParent(arguments);
+    },
+
+    afterRender: function() {
+        this.superclass.afterRender.apply(this, arguments);
+        this.down('map').map.zoomToMaxExtent();
+    },
+
+    setStore: function(store) {
+        var me = this;
+        var osg = this.down('ortstammdatengrid');
+        var map = this.down('map');
+
+        if (!store) {
+            var ortstore = Ext.create('Lada.store.Orte', {
+                defaultPageSize: 0,
+                listeners: {
+                    beforeload: {
+                        fn: function() {
+                            osg.setLoading(true);
+                            map.setLoading(true);
+                        }
+                    },
+                    load: {
+                        fn: function() {
+                            osg.setLoading(false);
+                            map.setLoading(false);
+                            osg.setStore(ortstore);
+                            map.addLocations(ortstore);
+                        }
+                    }
+                }
+            });
+        }
+        else {
+            osg.setStore(store);
+            map.addLocations(store);
+        }
+        this.connectListeners();
+        //enable buttons
+        me.down('toolbar button[action=add]').enable();
+        me.down('toolbar button[action=addMap]').enable();
+    },
+
+    getStore: function() {
+        return this.down('grid').getStore();
+    },
+
+    connectListeners: function() {
+        var osg = this.down('ortstammdatengrid');
+        var map = this.down('map');
+        map.addListener('featureselected', osg.selectOrt, osg);
+        osg.addListener('select', map.selectFeature, map);
+    }
+});

http://lada.wald.intevation.org