dustin@797: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@797: * Software engineering by Intevation GmbH dustin@797: * dustin@797: * This file is Free Software under the GNU GPL (v>=3) dustin@797: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@797: * the documentation coming with IMIS-Labordaten-Application for details. dustin@797: */ dustin@797: dustin@797: /** dustin@797: * Window to add a Ort to a Messprogramm dustin@797: */ mkrambach@1288: // TODO: This is >80% identical to Lada.view.form.Ortszuordnung. mkrambach@1288: // Differences: This has no ortszuordnung record. It only receives and sends mkrambach@1288: // an ortId mkrambach@1288: dustin@797: Ext.define('Lada.view.window.MessprogrammOrt', { dustin@797: extend: 'Ext.window.Window', dustin@797: alias: 'widget.messprogrammort', dustin@797: dustin@797: requires: [ mkrambach@1288: 'Lada.view.form.Ortserstellung', dustin@797: 'Lada.view.panel.Map', mkrambach@1288: 'Lada.view.grid.Orte' dustin@797: ], dustin@797: dustin@797: collapsible: true, dustin@797: maximizable: true, dustin@797: autoshow: true, mkrambach@1288: layout: 'fit', dustin@797: constrain: true, dustin@797: dustin@797: parentWindow: null, mkrambach@1288: mkrambach@1288: ortId: null, dustin@797: dustin@890: /** dustin@890: * This function initialises the Window dustin@890: */ dustin@797: initComponent: function() { dustin@797: var i18n = Lada.getApplication().bundle; dustin@797: dustin@797: this.title = i18n.getMsg('messprogrammort.window.title'); dustin@797: this.buttons = [{ dustin@797: text: i18n.getMsg('apply'), dustin@797: scope: this, dustin@797: handler: this.apply dustin@797: }, { dustin@797: text: i18n.getMsg('cancel'), dustin@797: scope: this, dustin@797: handler: function() { dustin@818: this.close(); dustin@797: this.parentWindow.down('messprogrammform') dustin@797: .ortWindow = null; dustin@797: } dustin@797: }]; dustin@797: dustin@797: // add listeners to change the window appearence when it becomes inactive dustin@797: this.on({ dustin@797: activate: function(){ dustin@797: this.getEl().removeCls('window-inactive'); dustin@797: }, dustin@797: deactivate: function(){ dustin@797: this.getEl().addCls('window-inactive'); dustin@818: }, dustin@818: close: function () { dustin@818: this.parentWindow.down('messprogrammform') dustin@818: .ortWindow = null; dustin@797: } dustin@797: }); dustin@797: dustin@797: this.items = [{ mkrambach@1288: layout: 'border', mkrambach@1288: bodyStyle: {background: '#fff'}, dustin@797: border: 0, dustin@797: items: [{ dustin@797: xtype: 'map', dustin@797: region: 'center', dustin@797: layout: 'border', mkrambach@1288: margin: '13, 5, 10, 5', mkrambach@1288: minHeight: 380, mkrambach@1288: externalOrteStore: true mkrambach@1288: }, { mkrambach@1288: xtype: 'panel', mkrambach@1288: layout: 'hbox', mkrambach@1288: border: 0, mkrambach@1288: margin: '0, 0, 10, 0', mkrambach@1288: dockedItems: [{ mkrambach@1288: xtype: 'toolbar', mkrambach@1288: dock: 'bottom', mkrambach@1294: ui: 'footer', mkrambach@1288: border: '0, 1, 1, 1', mkrambach@1288: style: { mkrambach@1288: borderBottom: '1px solid #b5b8c8 !important', mkrambach@1288: borderLeft: '1px solid #b5b8c8 !important', mkrambach@1288: borderRight: '1px solid #b5b8c8 !important' mkrambach@1288: }, mkrambach@1288: items: [{ mkrambach@1288: text: i18n.getMsg('ortszuordnung.form.setOrt'), mkrambach@1288: tooltip: i18n.getMsg('ortszuordnung.form.setOrt.qtip'), mkrambach@1288: icon: 'resources/img/dialog-ok-apply.png', mkrambach@1288: action: 'setOrt', mkrambach@1288: enableToggle: true, mkrambach@1288: disabled: true mkrambach@1288: }, '->', { mkrambach@1288: text: i18n.getMsg('save'), mkrambach@1288: tooltip: i18n.getMsg('save.qtip'), mkrambach@1288: icon: 'resources/img/dialog-ok-apply.png', mkrambach@1288: action: 'save', mkrambach@1288: disabled: true mkrambach@1288: }, { mkrambach@1288: text: i18n.getMsg('discard'), mkrambach@1288: tooltip: i18n.getMsg('discard.qtip'), mkrambach@1288: icon: 'resources/img/dialog-cancel.png', mkrambach@1288: action: 'discard', mkrambach@1288: disabled: true mkrambach@1288: }] mkrambach@1288: }], mkrambach@1288: items: [Ext.create('Lada.view.form.OrtInfo')] mkrambach@1288: }, { mkrambach@1288: region: 'south', mkrambach@1288: border: 0, mkrambach@1288: layout: 'fit', mkrambach@1288: name: 'ortgrid', mkrambach@1288: hidden: true, mkrambach@1288: maxHeight: 240, mkrambach@1288: items: [{ mkrambach@1288: xtype: 'ortstammdatengrid' mkrambach@1288: }], mkrambach@1288: dockedItems: [{ mkrambach@1288: xtype: 'toolbar', mkrambach@1288: dock: 'bottom', mkrambach@1288: border: '0, 1, 1, 1', mkrambach@1288: style: { mkrambach@1288: borderBottom: '1px solid #b5b8c8 !important', mkrambach@1288: borderLeft: '1px solid #b5b8c8 !important', mkrambach@1288: borderRight: '1px solid #b5b8c8 !important' mkrambach@1288: }, mkrambach@1288: items: [{ mkrambach@1288: xtype: 'textfield', mkrambach@1288: name: 'search', mkrambach@1288: labelWidth: 50, mkrambach@1288: enableKeyEvents: true, mkrambach@1288: fieldLabel: i18n.getMsg('ortszuordnung.ortsuche'), mkrambach@1288: }, '->', { mkrambach@1288: text: i18n.getMsg('orte.new'), mkrambach@1288: action: 'createort' mkrambach@1288: }, { mkrambach@1288: text: i18n.getMsg('orte.frommap'), mkrambach@1288: action: 'frommap' mkrambach@1288: }, { mkrambach@1288: text: i18n.getMsg('orte.clone'), mkrambach@1288: action: 'clone' mkrambach@1288: }] mkrambach@1288: }] dustin@797: }] dustin@797: }]; dustin@797: this.callParent(arguments); mkrambach@1288: //TODO: load the passed OrtId dustin@797: }, dustin@797: dustin@797: selectedFeature: function(context, args) { dustin@797: var feature = args[0]; dustin@797: if (feature.attributes.id && dustin@797: feature.attributes.id !== '') { raimund@1251: var record = Ext.data.StoreManager.get('orte').getById(feature.attributes.id); dustin@797: context.up('window').down('locationform').setRecord(record); dustin@797: context.up('window').down('locationform').setReadOnly(true); dustin@797: context.up('window').down('location').down('combobox').setValue(record.id); dustin@797: } dustin@797: else { dustin@797: context.up('window').down('locationform').setRecord(this.locationRecord); dustin@797: context.up('window').down('locationform').setReadOnly(false); dustin@797: } dustin@797: }, dustin@797: dustin@797: /** dustin@797: * updateDetails is used when a value is selected within the location combobox dustin@797: * When this function is called, the map element within the window dustin@797: * which is embedding this form is updated. dustin@797: * dustin@797: * Mostly the same as in Lada.controlle.form.Ort dustin@797: */ dustin@797: updateDetails: function(combobox, record) { dustin@797: var win = combobox.up('window'); dustin@797: var details = win.down('locationform'); dustin@797: //var id = record[0].get('id'); // We are interested in the cbox... dustin@797: var id = combobox.getValue(); dustin@797: dustin@797: if (details) { raimund@1251: var toLoad = Ext.data.StoreManager.get('orte').getById(id); dustin@797: win.down('locationform').setRecord(toLoad); raimund@1251: win.down('map').selectFeature(id, toLoad); dustin@797: } dustin@797: }, dustin@797: dustin@797: /** dustin@797: * Write the selected ortId into the record, and update the MessprogrammWindow. dustin@797: */ dustin@797: apply: function(button) { dustin@797: var win = button.up('window'); dustin@797: var ortId = win.down('location').down('combobox').value; dustin@797: if (this.parentWindow) { dustin@797: this.parentWindow.down('messprogrammform').down('location') dustin@797: .down('combobox').setValue(ortId); dustin@797: } dustin@797: dustin@797: this.parentWindow.down('messprogrammform') dustin@797: .ortWindow = null; dustin@797: this.close(); dustin@797: }, dustin@890: dustin@890: /** dustin@890: * Instructs the fields / forms listed in this method to set a message. dustin@890: * @param errors These Errors shall be shown dustin@890: * @param warnings These Warning shall be shown dustin@890: */ dustin@797: setMessages: function(errors, warnings) { dustin@797: //todo this is a stub dustin@797: }, dustin@797: dustin@890: /** dustin@890: * Instructs the fields / forms listed in this method to clear their messages. dustin@890: */ dustin@797: clearMessages: function() { dustin@797: //todo this is a stub dustin@797: } dustin@797: }); dustin@797: