dustin@757: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz dustin@757: * Software engineering by Intevation GmbH dustin@757: * dustin@757: * This file is Free Software under the GNU GPL (v>=3) dustin@757: * and comes with ABSOLUTELY NO WARRANTY! Check out dustin@757: * the documentation coming with IMIS-Labordaten-Application for details. dustin@757: */ dustin@757: dustin@757: /* dustin@757: * Window to edit a Messprogramm dustin@757: */ dustin@757: Ext.define('Lada.view.window.MessprogrammEdit', { dustin@757: extend: 'Ext.window.Window', dustin@757: alias: 'widget.messprogrammedit', dustin@757: dustin@757: requires: [ dustin@757: 'Lada.view.form.Messprogramm', dustin@757: 'Lada.view.grid.Messmethoden', dustin@757: ], dustin@757: dustin@757: collapsible: true, dustin@757: maximizable: true, dustin@757: autoShow: true, dustin@757: autoScroll: true, dustin@757: layout: 'fit', dustin@757: constrain: true, dustin@757: dustin@757: record: null, dustin@757: dustin@757: initComponent: function() { dustin@757: var i18n = Lada.getApplication().bundle; dustin@757: dustin@757: if (this.record === null) { dustin@757: Ext.Msg.create(i18n.getMsg('err.msg.generic.title'), dustin@757: i18n.getMsg('err.msg.novalidmessprogram')); dustin@757: this.callParent(arguments); dustin@757: return; dustin@757: } dustin@757: this.title = i18n.getMsg('messprogramm.window.edit.title'); dustin@757: this.buttons = [{ dustin@757: text: i18n.getMsg('close'), dustin@757: scope: this, dustin@757: handler: this.close dustin@757: }]; dustin@757: this.width = 700; dustin@757: dustin@757: // add listeners to change the window appearence when it becomes inactive dustin@757: this.on({ dustin@757: activate: function(){ dustin@757: this.getEl().removeCls('window-inactive'); dustin@757: }, dustin@757: deactivate: function(){ dustin@757: this.getEl().addCls('window-inactive'); dustin@757: } dustin@757: }); dustin@757: dustin@757: this.height = Ext.getBody().getViewSize().height - 30; dustin@757: // InitialConfig is the config object passed to the constructor on dustin@757: // creation of this window. We need to pass it throuh to the form as dustin@757: // we need the "Id" param to load the correct item. dustin@757: this.items = [{ dustin@757: border: 0, dustin@757: autoScroll: true, dustin@757: items: [{ dustin@757: xtype: 'messprogrammform', dustin@757: recordId: this.record.get('id') dustin@757: }, { dustin@757: //Messmethoden dustin@757: xtype: 'fieldset', dustin@757: title: i18n.getMsg('mmtmessprogramm.form.fieldset.title'), dustin@757: autoScroll: true, dustin@757: margin: 5, dustin@757: layout: { dustin@757: type: 'hbox', dustin@757: }, dustin@757: items: [{ dustin@757: xtype: 'messmethodengrid', dustin@758: //recordId: null, dustin@758: recordId: this.record.get('id'), dustin@757: flex: 1 dustin@757: }] dustin@757: }] dustin@757: }]; dustin@757: this.callParent(arguments); dustin@757: }, dustin@757: dustin@757: initData: function() { dustin@757: this.setLoading(true); dustin@757: this.clearMessages(); dustin@757: me = this; dustin@757: Ext.ClassManager.get('Lada.model.Messprogramm').load(this.record.get('id'), { dustin@757: failure: function(record, action) { dustin@757: me.setLoading(false); dustin@757: // TODO dustin@757: console.log('An unhandled Failure occured. See following Response and Record'); dustin@757: console.log(action); dustin@757: console.log(record); dustin@757: }, dustin@757: success: function(record, response) { dustin@757: this.down('messprogrammform').setRecord(record); dustin@757: this.record = record; dustin@757: dustin@758: //this.down('messmethodengrid').recordId = record.get('id'); dustin@757: var json = Ext.decode(response.response.responseText); dustin@757: if (json) { dustin@757: this.setMessages(json.errors, json.warnings); dustin@757: } dustin@757: // If the Messprogramm is ReadOnly, disable Inputfields and grids dustin@757: if (this.record.get('readonly') === true) { dustin@757: this.down('messprogrammform').setReadOnly(true); dustin@757: this.disableChildren(); dustin@757: } dustin@757: else { dustin@757: this.down('messprogrammform').setReadOnly(false); dustin@757: this.enableChildren(); dustin@757: } dustin@757: me.setLoading(false); dustin@757: }, dustin@757: scope: this dustin@757: }); dustin@757: }, dustin@757: dustin@757: //This was used in a Probewindow, I left it here for reference... dustin@757: /* dustin@757: enableAddMessungen: function() { dustin@757: this.down('fset[name=messungen]').down('messunggrid').setReadOnly(false); dustin@757: }, dustin@757: */ dustin@757: dustin@757: disableChildren: function() { dustin@758: // there are no children.... dustin@757: }, dustin@757: dustin@757: enableChildren: function() { dustin@757: // there are no children.... dustin@757: }, dustin@757: dustin@757: setMessages: function(errors, warnings) { dustin@757: this.down('messprogrammform').setMessages(errors, warnings); dustin@757: }, dustin@757: dustin@757: clearMessages: function() { dustin@757: this.down('messprogrammform').clearMessages(); dustin@757: } dustin@757: });