dustin@1013: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@1013: * Software engineering by Intevation GmbH dustin@1013: * dustin@1013: * This file is Free Software under the GNU GPL (v>=3) dustin@1013: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@1013: * the documentation coming with IMIS-Labordaten-Application for details. dustin@1013: */ dustin@1013: dustin@1013: /** dustin@1013: * Window to create/edit the Ort / Probe Relation dustin@1013: */ dustin@1013: Ext.define('Lada.view.window.Ortszuordnung', { dustin@1013: extend: 'Ext.window.Window', dustin@1013: alias: 'widget.ortszuordnungwindow', dustin@1013: dustin@1013: requires: [ dustin@1021: 'Lada.view.form.Ortszuordnung', mkrambach@1279: 'Lada.view.form.Ortserstellung', mkrambach@1288: 'Lada.view.panel.Map', mkrambach@1288: 'Lada.view.grid.Orte' dustin@1013: ], dustin@1013: dustin@1013: collapsible: true, dustin@1013: maximizable: true, dustin@1013: autoshow: true, raimund@1274: layout: 'fit', dustin@1013: constrain: true, dustin@1013: dustin@1013: probe: null, mkrambach@1288: dustin@1013: parentWindow: null, dustin@1013: record: null, dustin@1013: grid: null, dustin@1013: dustin@1013: /** dustin@1013: * This function initialises the Window dustin@1013: */ dustin@1013: initComponent: function() { dustin@1013: var i18n = Lada.getApplication().bundle; dustin@1013: this.title = i18n.getMsg('ortszuordnung.window.title'); dustin@1013: dustin@1013: if (this.record && this.probe) { dustin@1021: // A record be edited dustin@1013: this.title = i18n.getMsg('ortszuordnung.window.title') dustin@1013: + ' ' dustin@1013: + i18n.getMsg('ortszuordnung.window.title2') dustin@1013: + ' ' dustin@1013: + i18n.getMsg('probe') dustin@1013: + ' ' raimund@1138: + this.probe.get('hauptprobenNr') dustin@1013: + ' ' dustin@1013: + i18n.getMsg('edit'); dustin@1013: } dustin@1013: else if (this.probe) { dustin@1013: // A new record will be created dustin@1013: this.title = i18n.getMsg('ortszuordnung.window.title') dustin@1013: + ' ' dustin@1013: + i18n.getMsg('ortszuordnung.window.title2') dustin@1013: + ' ' dustin@1013: + i18n.getMsg('probe') dustin@1013: + ' ' raimund@1138: + this.probe.get('hauptprobenNr') dustin@1013: + ' ' dustin@1013: + i18n.getMsg('create'); dustin@1013: } dustin@1013: this.buttons = [{ dustin@1013: text: i18n.getMsg('close'), dustin@1013: scope: this, dustin@1013: handler: this.close dustin@1013: }]; dustin@1013: this.width = 900; raimund@1274: this.height = 465; dustin@1013: this.bodyStyle = {background: '#fff'}; dustin@1013: dustin@1013: // add listeners to change the window appearence when it becomes inactive dustin@1013: this.on({ dustin@1013: activate: function(){ dustin@1013: this.getEl().removeCls('window-inactive'); dustin@1013: }, dustin@1013: deactivate: function(){ dustin@1013: this.getEl().addCls('window-inactive'); dustin@1013: } dustin@1013: }); dustin@1013: dustin@1013: this.items = [{ raimund@1274: layout: 'border', raimund@1274: bodyStyle: {background: '#fff'}, raimund@1274: border: 0, raimund@1274: items: [{ raimund@1274: xtype: 'map', raimund@1274: region: 'center', raimund@1274: layout: 'border', raimund@1274: margin: '13, 5, 10, 5', raimund@1274: minHeight: 380, raimund@1274: externalOrteStore: true raimund@1274: }, { raimund@1274: xtype: 'ortszuordnungform', raimund@1274: region: 'east', raimund@1274: minHeight: 380, raimund@1274: }, { raimund@1274: region: 'south', raimund@1274: border: 0, raimund@1274: layout: 'fit', raimund@1274: name: 'ortgrid', raimund@1274: hidden: true, mkrambach@1279: maxHeight: 240, raimund@1274: items: [{ mkrambach@1279: xtype: 'ortstammdatengrid' raimund@1274: }], raimund@1274: dockedItems: [{ raimund@1274: xtype: 'toolbar', raimund@1274: dock: 'bottom', raimund@1274: border: '0, 1, 1, 1', raimund@1274: style: { raimund@1274: borderBottom: '1px solid #b5b8c8 !important', raimund@1274: borderLeft: '1px solid #b5b8c8 !important', raimund@1274: borderRight: '1px solid #b5b8c8 !important' raimund@1274: }, raimund@1274: items: [{ raimund@1274: xtype: 'textfield', raimund@1287: name: 'search', raimund@1274: labelWidth: 50, raimund@1287: enableKeyEvents: true, raimund@1274: fieldLabel: i18n.getMsg('ortszuordnung.ortsuche'), raimund@1274: }, '->', { raimund@1274: text: i18n.getMsg('orte.new'), mkrambach@1279: action: 'createort' raimund@1274: }, { raimund@1274: text: i18n.getMsg('orte.frommap'), mkrambach@1279: action: 'frommap' raimund@1274: }, { raimund@1274: text: i18n.getMsg('orte.clone'), mkrambach@1279: action: 'clone' raimund@1274: }] raimund@1274: }] raimund@1274: }] dustin@1013: }]; mkrambach@1279: dustin@1013: this.callParent(arguments); dustin@1013: }, dustin@1013: dustin@1013: /** dustin@1013: * Initialise the Data of this Window dustin@1013: */ dustin@1013: initData: function() { raimund@1274: var me = this; raimund@1134: if (!this.record) { raimund@1134: this.record = Ext.create('Lada.model.Ortszuordnung'); raimund@1134: if (!this.record.get('letzteAenderung')) { raimund@1134: this.record.data.letzteAenderung = new Date(); raimund@1134: } raimund@1134: this.record.set('probeId', this.probe.get('id')); raimund@1134: } dustin@1013: this.down('ortszuordnungform').setRecord(this.record); raimund@1274: var map = this.down('map'); raimund@1274: var osg = this.down('ortstammdatengrid'); mkrambach@1284: this.ortstore = Ext.create('Lada.store.Orte', { raimund@1274: defaultPageSize: 0, raimund@1274: autoLoad: false, raimund@1274: listeners: { raimund@1274: beforeload: { raimund@1274: fn: function() { raimund@1274: osg.setLoading(true); raimund@1274: map.setLoading(true); raimund@1274: } raimund@1274: }, raimund@1274: load: { raimund@1274: fn: function() { raimund@1274: osg.setLoading(false); raimund@1274: map.setLoading(false); mkrambach@1284: osg.setStore(me.ortstore); mkrambach@1284: map.addLocations(me.ortstore); mkrambach@1279: map.featureLayer.setVisibility(false); mkrambach@1279: map.selectedFeatureLayer = new OpenLayers.Layer.Vector( mkrambach@1279: 'gewählter Messpunkt', { mkrambach@1279: styleMap: new OpenLayers.StyleMap({ mkrambach@1279: externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png', mkrambach@1279: pointRadius: 10, mkrambach@1279: label: '${bez}', mkrambach@1279: labelAlign: 'rt', mkrambach@1279: fontColor: 'blue', mkrambach@1279: fontWeight: 'bold', mkrambach@1279: }), mkrambach@1279: displayInLayerSwitcher: false, mkrambach@1279: projection: new OpenLayers.Projection('EPSG:3857') mkrambach@1279: }); mkrambach@1279: map.map.addLayer(map.selectedFeatureLayer); mkrambach@1279: map.selectedFeatureLayer.setZIndex(499); mkrambach@1279: var ortId = me.record.get('ortId'); mkrambach@1279: if (ortId){ mkrambach@1279: var feat = map.featureLayer.getFeaturesByAttribute('id', ortId)[0]; mkrambach@1279: map.selectControl.select(feat); mkrambach@1279: } raimund@1274: } raimund@1274: } raimund@1274: } raimund@1274: }); mkrambach@1284: this.ortstore.load(); mkrambach@1279: map.addListener('featureselected', osg.selectOrt, osg); mkrambach@1279: osg.addListener('select', map.selectFeature, map); dustin@1021: }, dustin@1021: dustin@1021: /** dustin@1021: * @private dustin@1021: * Override to display and update the map view in the panel. dustin@1021: */ dustin@1021: afterRender: function(){ dustin@1021: this.superclass.afterRender.apply(this, arguments); raimund@1274: var map = this.down('map'); raimund@1274: map.map.addControl(new OpenLayers.Control.LayerSwitcher()); dustin@1013: }, dustin@1013: dustin@1013: /** dustin@1013: * Instructs the fields / forms listed in this method to set a message. dustin@1013: * @param errors These Errors shall be shown dustin@1013: * @param warnings These Warning shall be shown dustin@1013: */ dustin@1013: setMessages: function(errors, warnings) { dustin@1013: //todo this is a stub dustin@1013: }, dustin@1013: dustin@1013: /** dustin@1013: * Instructs the fields / forms listed in this method to clear their messages. dustin@1013: */ dustin@1013: clearMessages: function() { dustin@1013: //todo this is a stub dustin@1013: } dustin@1013: }); dustin@1013: