raimund@606: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@606: * Software engineering by Intevation GmbH raimund@606: * raimund@606: * This file is Free Software under the GNU GPL (v>=3) raimund@606: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@606: * the documentation coming with IMIS-Labordaten-Application for details. raimund@606: */ raimund@606: raimund@606: /* raimund@606: * Window to edit a Messung raimund@606: */ raimund@606: Ext.define('Lada.view.window.OrtEdit', { raimund@606: extend: 'Ext.window.Window', raimund@606: alias: 'widget.ortedit', raimund@606: raimund@606: requires: [ raimund@606: 'Lada.view.panel.Map', raimund@606: 'Lada.view.form.Ort', raimund@606: 'Lada.view.form.Location' raimund@606: ], raimund@606: raimund@606: collapsible: true, raimund@606: maximizable: true, raimund@606: autoshow: true, raimund@606: layout: 'border', dustin@688: constrain: true, raimund@606: raimund@690: parentWindow: null, raimund@690: probe: null, raimund@606: record: null, raimund@644: grid: null, raimund@606: raimund@606: initComponent: function() { raimund@606: if (this.record === null) { raimund@606: Ext.Msg.alert('Kein valider Ort ausgewählt!'); raimund@606: this.callParent(arguments); raimund@606: return; raimund@606: } raimund@690: if (this.probe === null) { raimund@690: Ext.Msg.alert('Zu dem Ort existiert keine Probe!'); raimund@690: this.callParent(arguments); raimund@690: return; raimund@690: } raimund@606: this.title = 'Ort'; raimund@606: this.buttons = [{ raimund@606: text: 'Schließen', raimund@606: scope: this, raimund@606: handler: this.close raimund@606: }]; raimund@606: this.width = 900; raimund@606: this.height = 515; raimund@606: this.bodyStyle = {background: '#fff'}; raimund@606: dustin@709: // add listeners to change the window appearence when it becomes inactive dustin@709: this.on({ dustin@709: activate: function(){ dustin@709: this.getEl().removeCls('window-inactive'); dustin@709: }, dustin@709: deactivate: function(){ dustin@709: this.getEl().addCls('window-inactive'); dustin@709: } dustin@709: }); dustin@709: raimund@606: this.items = [{ raimund@606: region: 'west', raimund@606: border: 0, raimund@606: layout: 'vbox', raimund@606: items: [{ raimund@606: xtype: 'ortform', raimund@606: margin: 5, raimund@606: recordId: this.record.get('id') raimund@606: }, { raimund@606: xtype: 'locationform', raimund@606: margin: 5, raimund@606: recordId: this.record.get('id') raimund@606: }] raimund@606: }, { raimund@606: xtype: 'fset', raimund@606: bodyStyle: { raimund@606: background: '#fff' raimund@606: }, raimund@606: layout: 'border', raimund@606: name: 'mapfield', raimund@606: title: 'Karte', raimund@606: region: 'center', raimund@606: padding: '5, 5', raimund@606: margin: 5, raimund@606: items: [{ raimund@606: xtype: 'map', raimund@606: region: 'center', raimund@606: layout: 'border', raimund@614: record: this.record, raimund@606: bodyStyle: { raimund@606: background: '#fff' raimund@606: }, raimund@606: name: 'map' raimund@606: }] raimund@606: }]; raimund@606: this.callParent(arguments); raimund@606: }, raimund@606: raimund@606: initData: function() { raimund@690: Ext.ClassManager.get('Lada.model.Ort').load(this.record.get('id'), { raimund@690: failure: function(record, action) { raimund@690: // TODO raimund@690: }, raimund@690: success: function(record, response) { raimund@690: var me = this; raimund@726: if (record.get('treeModified') < record.get('parentModified')) { raimund@690: Ext.Msg.show({ raimund@690: title: 'Probe nicht aktuell!', raimund@690: msg: 'Die zugehörige Probe wurde verändert.\nMöchten Sie zu der Probe zurückkehren und neu laden?\nOhne das erneute Laden der Probe wird das Speichern des Ortes nicht möglich sein.', raimund@690: buttons: Ext.Msg.OKCANCEL, raimund@690: icon: Ext.Msg.WARNING, raimund@690: closable: false, raimund@690: fn: function(button) { raimund@690: if (button === 'ok') { raimund@690: me.close(); raimund@690: me.parentWindow.initData(); raimund@690: } raimund@690: else { raimund@690: me.record.set('treeModified', me.probe.get('treeModified')); raimund@690: } raimund@690: } raimund@690: }); raimund@690: } raimund@690: this.down('ortform').setRecord(record); raimund@690: this.record = record; raimund@690: }, raimund@690: scope: this raimund@690: }); raimund@606: Ext.ClassManager.get('Lada.model.Location').load(this.record.get('ort'), { raimund@606: failure: function(record, action) { raimund@606: // TODO raimund@606: }, raimund@606: success: function(record, response) { raimund@606: this.down('locationform').setRecord(record); raimund@606: this.down('locationform').setReadOnly(true); raimund@606: }, raimund@606: scope: this raimund@606: }); raimund@606: }, raimund@606: raimund@606: setMessages: function(errors, warnings) { raimund@606: //todo this is a stub raimund@606: }, raimund@606: raimund@606: clearMessages: function() { raimund@606: //todo this is a stub raimund@606: } raimund@606: });