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; dustin@1021: 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, dustin@1021: collapsible: true, raimund@1049: region: 'east' dustin@1021: }, { dustin@1021: xtype: 'map', dustin@1021: region: 'center', 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]); dustin@1021: }, dustin@1021: expand: function() { dustin@1021: this.map.addControl(new OpenLayers.Control.ScaleLine()); dustin@1021: } dustin@1021: } raimund@1049: }]; dustin@1021: 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'); dustin@1021: dustin@1021: if (!store) { dustin@1021: var ortstore = Ext.create('Lada.store.Orte', { dustin@1021: defaultPageSize: 0, dustin@1021: listeners: { dustin@1021: beforeload: { dustin@1021: fn: function() { dustin@1021: osg.setLoading(true); dustin@1021: map.setLoading(true); dustin@1021: } dustin@1021: }, dustin@1021: load: { dustin@1021: fn: function() { dustin@1021: osg.setLoading(false); dustin@1021: map.setLoading(false); dustin@1021: osg.setStore(ortstore); dustin@1021: map.addLocations(ortstore); dustin@1021: } dustin@1021: } dustin@1021: } dustin@1021: }); dustin@1021: } dustin@1021: else { raimund@1344: store.clearFilter(true); dustin@1021: osg.setStore(store); dustin@1021: map.addLocations(store); dustin@1021: } raimund@1049: this.connectListeners(); dustin@1021: //enable buttons dustin@1021: me.down('toolbar button[action=add]').enable(); dustin@1021: me.down('toolbar button[action=addMap]').enable(); raimund@1049: }, raimund@1049: raimund@1049: getStore: function() { raimund@1049: 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: });