dustin@1021: Ext.define('Lada.view.panel.Ort', { dustin@1021: extend: 'Ext.panel.Panel', dustin@1021: alias: 'widget.ortpanel', dustin@1021: dustin@1021: requires: [ dustin@1021: 'Lada.view.panel.Map', dustin@1021: 'Lada.view.grid.Orte' dustin@1021: ], dustin@1021: dustin@1021: width: '100%', dustin@1021: //height: 200, dustin@1021: dustin@1021: layout: { raimund@1049: type: 'border' dustin@1021: }, dustin@1021: toolbarPos: 'top', dustin@1021: raimund@1050: editableGrid: true, raimund@1050: dustin@1021: initComponent: function() { dustin@1021: var i18n = Lada.getApplication().bundle; mstanko@1420: dustin@1021: // Different Layout of toolbar depending on the bars position. dustin@1021: if (this.toolbarPos == 'top') { dustin@1021: this.dockedItems = [{ dustin@1021: xtype: 'toolbar', dustin@1021: dock: 'top', dustin@1021: items: [{ dustin@1021: xtype: 'tbtext', dustin@1021: text: i18n.getMsg('orte.gridTitle') dustin@1021: }, dustin@1021: '->', dustin@1021: { dustin@1021: text: i18n.getMsg('map.button.add'), dustin@1021: icon: 'resources/img/list-add.png', dustin@1021: action: 'addMap', dustin@1021: disabled: true // disabled on startup, will be enabled by setStore dustin@1021: }, { dustin@1021: text: i18n.getMsg('orte.button.add'), dustin@1021: icon: 'resources/img/list-add.png', dustin@1021: action: 'add', dustin@1021: disabled: true // disabled on startup, will be enabled by setStore dustin@1021: }, { dustin@1021: text: i18n.getMsg('orte.button.delete'), dustin@1021: icon: 'resources/img/list-remove.png', dustin@1021: action: 'delete', dustin@1021: disabled: true // disabled on startup, will be enabled by controller if necessary dustin@1021: }] dustin@1021: }]; dustin@1021: } dustin@1021: else { dustin@1021: this.dockedItems = [{ dustin@1021: xtype: 'toolbar', dustin@1021: dock: this.toolbarPos, dustin@1021: items: [ '->', dustin@1021: { dustin@1021: text: i18n.getMsg('map.button.add'), dustin@1021: icon: 'resources/img/list-add.png', dustin@1021: action: 'addMap', dustin@1021: disabled: true // disabled on startup, will be enabled by setStore dustin@1021: }, { dustin@1021: text: i18n.getMsg('orte.button.add'), dustin@1021: icon: 'resources/img/list-add.png', dustin@1021: action: 'add', dustin@1021: disabled: true // disabled on startup, will be enabled by setStore dustin@1021: }] dustin@1021: }]; dustin@1021: } dustin@1021: dustin@1021: this.items = [{ dustin@1021: xtype: 'ortstammdatengrid', dustin@1021: width: '60%', raimund@1050: editableGrid: this.editableGrid, mstanko@1420: region: 'center' dustin@1021: }, { dustin@1021: xtype: 'map', mstanko@1420: flex: 1, mstanko@1420: collapsible: true, mstanko@1420: region: 'east', dustin@1021: layout: 'border', dustin@1021: title: i18n.getMsg('map.title'), dustin@1021: externalOrteStore: true, dustin@1021: listeners: { dustin@1021: beforecollapse: function() { dustin@1021: var c = this.map.getControlsByClass('OpenLayers.Control.ScaleLine'); dustin@1021: this.map.removeControl(c[0]); mstanko@1420: for (i = 0; i < this.map.layers.length; i++) { mstanko@1420: this.map.layers[i].setVisibility(false); mstanko@1420: } dustin@1021: }, dustin@1021: expand: function() { dustin@1021: this.map.addControl(new OpenLayers.Control.ScaleLine()); mstanko@1420: for (i = 0; i < this.map.layers.length; i++) { mstanko@1420: this.map.layers[i].setVisibility(true); mstanko@1420: } dustin@1021: } dustin@1021: } raimund@1049: }]; dustin@1021: this.callParent(arguments); dustin@1021: }, dustin@1021: raimund@1049: afterRender: function() { raimund@1049: this.superclass.afterRender.apply(this, arguments); mkrambach@1279: this.down('map').map.zoomTo(6); raimund@1049: }, raimund@1049: dustin@1021: setStore: function(store) { dustin@1021: var me = this; dustin@1021: var osg = this.down('ortstammdatengrid'); dustin@1021: var map = this.down('map'); mkrambach@1361: osg.setLoading(true); mkrambach@1361: map.setLoading(true); mkrambach@1364: var ortstore = store; mkrambach@1364: if (!ortstore) { mkrambach@1364: ortstore = Ext.data.StoreManager.get('orte'); dustin@1021: } mkrambach@1364: ortstore.clearFilter(true); mkrambach@1364: osg.setStore(ortstore); mkrambach@1364: map.addLocations(ortstore); mkrambach@1364: me.down('toolbar button[action=add]').enable(); mkrambach@1364: me.down('toolbar button[action=addMap]').enable(); mkrambach@1364: me.connectListeners(); raimund@1049: }, raimund@1049: raimund@1049: getStore: function() { mkrambach@1364: return this.down('grid').getStore(); raimund@1049: }, raimund@1049: raimund@1049: connectListeners: function() { raimund@1049: var osg = this.down('ortstammdatengrid'); raimund@1049: var map = this.down('map'); raimund@1049: map.addListener('featureselected', osg.selectOrt, osg); raimund@1049: osg.addListener('select', map.selectFeature, map); dustin@1021: } dustin@1021: });