# HG changeset patch # User Dustin Demuth # Date 1432133283 -7200 # Node ID b8fd43021c2979922847238d6b56f8e61a51fe0b # Parent 7267bae1d43f9df13e275ac23cffe141e12723ef Added a Window to alter Orte of a Messprogramm diff -r 7267bae1d43f -r b8fd43021c29 app/controller/form/Messprogramm.js --- a/app/controller/form/Messprogramm.js Wed May 20 14:19:12 2015 +0200 +++ b/app/controller/form/Messprogramm.js Wed May 20 16:48:03 2015 +0200 @@ -12,6 +12,10 @@ Ext.define('Lada.controller.form.Messprogramm', { extend: 'Ext.app.Controller', + requires: [ + 'Lada.view.window.MessprogrammOrt' + ], + /** * Initialize the Controller */ @@ -23,9 +27,15 @@ 'messprogrammform button[action=discard]': { click: this.discard }, + 'messprogrammform button[action=ort]': { + click: this.editOrtWindow + }, 'messprogrammform': { dirtychange: this.dirtyForm }, + 'messprogrammform location combobox': { + select: this.syncOrtWindow + }, 'messprogrammform datetime textfield': { blur: this.checkDatePeriod }, @@ -55,6 +65,43 @@ var record = form.getRecord(); form.populateIntervall(record, field.getValue()); }, + /** + * The function will open a new Window to edit the Ort of a Messprogramm + */ + editOrtWindow: function(button) { + var formPanel = button.up('form'); + //Only Open if the WIndow does not exist, else focus + if (!formPanel.ortWindow) { + var data = formPanel.getForm().getFieldValues(true); + formPanel.ortWindow = Ext.create('Lada.view.window.MessprogrammOrt', { + record: formPanel.getRecord(), + parentWindow: formPanel.up('window') + }); + formPanel.ortWindow.show(); + formPanel.ortWindow.initData(); + } + else { + formPanel.ortWindow.focus(); + formPanel.ortWindow.setActive(true); + } + }, + + /** + * When a OrtWindow exist, and the value of the location combobox is changed, update the window. + */ + syncOrtWindow: function(combo, record){ + var formPanel = combo.up('messprogrammform'); + if (formPanel.ortWindow) { + var ortwindowlocation = formPanel + .ortWindow.down('location') + var ortwindowcombo = ortwindowlocation + .down('combobox'); + + ortwindowcombo.select(combo.getValue()); + ortwindowlocation.fireEvent('select', + ortwindowcombo, ortwindowcombo.record); + } + }, /** * When the Slider was used, diff -r 7267bae1d43f -r b8fd43021c29 app/view/form/Messprogramm.js --- a/app/view/form/Messprogramm.js Wed May 20 14:19:12 2015 +0200 +++ b/app/view/form/Messprogramm.js Wed May 20 16:48:03 2015 +0200 @@ -25,6 +25,7 @@ 'Lada.model.Messprogramm', 'Lada.model.MmtMessprogramm', 'Lada.view.widget.Probenintervall', + 'Lada.view.widget.Location', 'Lada.view.widget.ProbenintervallSlider', 'Lada.view.widget.base.Datetime', 'Lada.view.widget.base.DateField' @@ -36,6 +37,7 @@ border: 0, recordId: null, + ortWindow: null, trackResetOnLoad: true, @@ -98,12 +100,31 @@ allowBlank: false, editable: true }, { - xtype: 'textarea', //TODO: we need a widget which is capable of handling errormsg. + xtype: 'textarea', //TODO: we might need a widget which is capable of handling errormsg. name: 'probeKommentar', labelAlign: 'top', fieldLabel: i18n.getMsg('probeKommentar'), labelwidth: 135, anchor: '100%' + }, { + layout: 'hbox', + border: 0, + align: 'stretch', + items: [{ + xtype: 'location', + name: 'ortId', + fieldLabel: i18n.getMsg('ortId'), + labelWidth: 80, + allowBlank: true, + forceSelection: true, + editable: false + }, { + xtype: 'button', + name: 'ortIdButton', + margin: '0 0 0 5', + text: i18n.getMsg('messprogrammort.button.title'), + action: 'ort' + }] }] }, { border: 0, diff -r 7267bae1d43f -r b8fd43021c29 app/view/window/MessprogrammOrt.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/window/MessprogrammOrt.js Wed May 20 16:48:03 2015 +0200 @@ -0,0 +1,233 @@ +/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU GPL (v>=3) + * and comes with ABSOLUTELY NO WARRANTY! Check out + * the documentation coming with IMIS-Labordaten-Application for details. + */ + +/** + * Window to add a Ort to a Messprogramm + */ +Ext.define('Lada.view.window.MessprogrammOrt', { + extend: 'Ext.window.Window', + alias: 'widget.messprogrammort', + + requires: [ + 'Lada.model.Ort', + 'Lada.view.panel.Map', + 'Lada.view.widget.Location', + 'Lada.view.form.Location' + ], + + collapsible: true, + maximizable: true, + autoshow: true, + layout: 'border', + constrain: true, + + parentWindow: null, + record: null, + + initComponent: function() { + var i18n = Lada.getApplication().bundle; + + this.title = i18n.getMsg('messprogrammort.window.title'); + this.buttons = [{ + text: i18n.getMsg('apply'), + scope: this, + handler: this.apply + }, { + text: i18n.getMsg('cancel'), + scope: this, + handler: function() { + this.close() + this.parentWindow.down('messprogrammform') + .ortWindow = null; + } + }]; + this.width = 900; + this.height = 515; + this.bodyStyle = {background: '#fff'}; + + // add listeners to change the window appearence when it becomes inactive + this.on({ + activate: function(){ + this.getEl().removeCls('window-inactive'); + }, + deactivate: function(){ + this.getEl().addCls('window-inactive'); + } + }); + + this.items = [{ + region: 'west', + border: 0, + layout: 'vbox', + items: [{ + xtype: 'fieldset', + title: i18n.getMsg('ortId'), + margin: 5, + items: [{ + border: 0, + margin: '0, 0, 10, 0', + items: [{ + xtype: 'location', + fieldLabel: i18n.getMsg('ortId'), + labelWidth: 80, + width: 280, + forceSelection: true, + name: 'ortId', + listeners: {//Update MapPanel etc... + select: this.updateDetails + } + }] + }] + }, { + xtype: 'locationform', + margin: 5, + recordId: this.record.get('ortId') + }] + }, { + xtype: 'fset', + bodyStyle: { + background: '#fff' + }, + layout: 'border', + name: 'mapfield', + title: 'Karte', + region: 'center', + padding: '5, 5', + margin: 5, + items: [{ + xtype: 'map', + region: 'center', + layout: 'border', + record: this.record.get('ortId') ? this.record : null, + bodyStyle: { + background: '#fff' + }, + name: 'map', + listeners: { //A listener which listens to the mappanels featureselected event + featureselected: this.selectedFeature + } + }] + }]; + this.callParent(arguments); + }, + + initData: function() { + //Only do this if an OrtId exists... + var ortId = this.record.get('ortId'); + + if (ortId) { + Ext.ClassManager.get('Lada.model.Ort').load(ortId, { + failure: function(record, action) { + // TODO + }, + success: function(record, response) { + var me = this; + if (record.get('treeModified') < record.get('parentModified')) { + Ext.Msg.show({ + title: 'Messprogramm nicht aktuell!', + msg: 'Das zugehörige Messprogramm wurde verändert.\nMöchten Sie zu dem Messprogramm zurückkehren und neu laden?\nOhne das erneute Laden des Messprogrammes wird das Speichern des Ortes nicht möglich sein.', + buttons: Ext.Msg.OKCANCEL, + icon: Ext.Msg.WARNING, + closable: false, + fn: function(button) { + if (button === 'ok') { + me.close(); + me.parentWindow.initData(); + me.parentWindow.down('messprogrammform') + .ortWindow = null; + } + else { + me.record.set('treeModified', me.probe.get('treeModified')); + } + } + }); + } + this.record = record; + }, + scope: this + }); + } + }, + + /** + * @private + * Override to display and update the map view in the panel. + */ + afterRender: function(){ + this.superclass.afterRender.apply(this, arguments); + var map = this.down('map'); + if (this.record.get('ortId')) { + map.selectFeature(this.record.get('ortId')); + } + else { + map.map.zoomToMaxExtent(); + } + }, + + /** + * This function is used by the MapPanel, when a Feature was selected + */ + selectedFeature: function(context, args) { + var feature = args[0]; + if (feature.attributes.id && + feature.attributes.id !== '') { + var record = Ext.data.StoreManager.get('locations').getById(feature.attributes.id); + context.up('window').down('locationform').setRecord(record); + context.up('window').down('locationform').setReadOnly(true); + context.up('window').down('location').down('combobox').setValue(record.id); + } + else { + context.up('window').down('locationform').setRecord(this.locationRecord); + context.up('window').down('locationform').setReadOnly(false); + } + }, + + /** + * updateDetails is used when a value is selected within the location combobox + * When this function is called, the map element within the window + * which is embedding this form is updated. + * + * Mostly the same as in Lada.controlle.form.Ort + */ + updateDetails: function(combobox, record) { + var win = combobox.up('window'); + var details = win.down('locationform'); + //var id = record[0].get('id'); // We are interested in the cbox... + var id = combobox.getValue(); + + if (details) { + var toLoad = Ext.data.StoreManager.get('locations').getById(id); + win.down('locationform').setRecord(toLoad); + win.down('map').selectFeature(id); + } + }, + + /** + * Write the selected ortId into the record, and update the MessprogrammWindow. + */ + apply: function(button) { + var win = button.up('window'); + var ortId = win.down('location').down('combobox').value; + if (this.parentWindow) { + this.parentWindow.down('messprogrammform').down('location') + .down('combobox').setValue(ortId); + } + + this.parentWindow.down('messprogrammform') + .ortWindow = null; + this.close(); + }, + setMessages: function(errors, warnings) { + //todo this is a stub + }, + + clearMessages: function() { + //todo this is a stub + } +}); + diff -r 7267bae1d43f -r b8fd43021c29 resources/i18n/Lada_de-DE.properties --- a/resources/i18n/Lada_de-DE.properties Wed May 20 14:19:12 2015 +0200 +++ b/resources/i18n/Lada_de-DE.properties Wed May 20 16:48:03 2015 +0200 @@ -49,6 +49,7 @@ netzbetreiberId:Netzbetreiber mediaDesk:Deskriptoren umwId:Umweltbereich +ortId:Ort probenintervall:Probenintervall teilintervallVon:Teilintervall Von teilintervallBis:Teilintervall Bis @@ -85,6 +86,8 @@ gpfm.window.title:Proben aus Messprogramm erzeugen messprogramm.form.fieldset.title:Messprogramm mmtmessprogramm.form.fieldset.title:Messmethode & Nuklide +messprogrammort.window.title:Ort für Messprogramm festlegen +messprogrammort.button.title:Ort angeben # Actions add:Hinzufügen @@ -101,6 +104,7 @@ nameofmessprogramm:Erzeuge Proben aus dem Messprogramm messprogtimeperiod:für den Zeitraum select:Auswählen +apply:Übernehmen ## # Msg: