raimund@548: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@548: * Software engineering by Intevation GmbH raimund@548: * raimund@548: * This file is Free Software under the GNU GPL (v>=3) raimund@548: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@548: * the documentation coming with IMIS-Labordaten-Application for details. raimund@548: */ raimund@548: raimund@548: /* raimund@548: * Formular to edit a Probe raimund@548: */ raimund@548: Ext.define('Lada.view.form.Probe', { raimund@548: extend: 'Ext.form.Panel', raimund@548: alias: 'widget.probeform', raimund@548: requires: [ raimund@548: 'Lada.view.widget.Datenbasis', raimund@555: 'Lada.view.widget.Messstelle', raimund@548: 'Lada.view.widget.Netzbetreiber', raimund@548: 'Lada.view.widget.Betriebsart', raimund@548: 'Lada.view.widget.Testdatensatz', raimund@548: 'Lada.view.widget.Probenart', raimund@548: 'Lada.view.widget.Umwelt', raimund@548: 'Lada.view.widget.base.TextField', raimund@548: 'Lada.view.widget.base.Datetime', raimund@548: 'Lada.view.widget.base.FieldSet', dustin@646: 'Lada.view.widget.base.DateField', dustin@646: 'Lada.model.Probe', raimund@548: ], raimund@548: raimund@548: model: 'Lada.model.Probe', raimund@548: minWidth: 650, raimund@548: margin: 5, raimund@548: border: 0, raimund@548: raimund@548: recordId: null, raimund@548: raimund@548: trackResetOnLoad: true, raimund@548: raimund@548: initComponent: function() { raimund@548: var me = this; raimund@548: this.items = [{ raimund@548: xtype: 'fieldset', raimund@548: title: 'Allgemein', raimund@548: items: [{ raimund@548: border: 0, raimund@548: margin: '0, 0, 10, 0', raimund@548: dockedItems: [{ raimund@548: xtype: 'toolbar', raimund@548: dock: 'bottom', raimund@548: border: '0, 1, 1, 1', raimund@548: style: { raimund@548: borderBottom: '1px solid #b5b8c8 !important', raimund@548: borderLeft: '1px solid #b5b8c8 !important', raimund@548: borderRight: '1px solid #b5b8c8 !important' raimund@548: }, raimund@548: items: ['->', { raimund@548: text: 'Speichern', raimund@548: qtip: 'Daten speichern', raimund@548: icon: 'resources/img/dialog-ok-apply.png', raimund@548: action: 'save', raimund@548: disabled: true raimund@548: }, { raimund@548: text: 'Verwerfen', raimund@548: qtip: 'Änderungen verwerfen', raimund@548: icon: 'resources/img/dialog-cancel.png', raimund@548: action: 'discard', raimund@548: disabled: true raimund@548: }] raimund@548: }], raimund@548: items: [{ raimund@548: layout: 'hbox', raimund@548: border: 0, raimund@548: items: [{ raimund@548: border: 0, raimund@548: width: '50%', raimund@548: minWidth: 290, raimund@548: layout: { raimund@548: type: 'vbox', raimund@548: align: 'stretch' raimund@548: }, raimund@548: margin: '0, 10, 0, 0', raimund@548: items: [{ raimund@555: xtype: 'messstelle', raimund@548: name: 'mstId', raimund@548: fieldLabel: 'Messstelle', raimund@548: labelWidth: 135, raimund@548: allowBlank: false raimund@548: }, { raimund@548: xtype: 'tfield', raimund@548: name: 'hauptprobenNr', raimund@548: maxLength: 20, raimund@548: fieldLabel: 'Hauptprobennr.', raimund@548: labelWidth: 135 raimund@548: }] raimund@548: }, { raimund@548: border: 0, raimund@548: width: '50%', raimund@548: minWidth: 300, dustin@623: margin: '0, 1, 0, 0', raimund@548: items: [{ raimund@548: xtype: 'fset', raimund@548: title: 'Erweiterte Angaben', raimund@548: collapsible: true, raimund@548: collapsed: true, raimund@548: items: [{ raimund@548: xtype: 'datenbasis', raimund@548: editable: false, raimund@548: name: 'datenbasisId', raimund@548: fieldLabel: 'Datenbasis', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: }, { raimund@548: xtype: 'betriebsart', raimund@548: name: 'baId', raimund@548: fieldLabel: 'Betriebsart', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: }, { raimund@548: xtype: 'testdatensatz', raimund@548: name: 'test', raimund@548: fieldLabel: 'Testdatensatz', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: allowBlank: false, raimund@548: }, { raimund@548: xtype: 'probenart', raimund@548: editable: false, raimund@548: name: 'probenartId', raimund@548: fieldLabel: 'Probenart', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: allowBlank: false, raimund@548: }, { raimund@548: xtype: 'numberfield', raimund@548: allowDecimals: false, raimund@548: name: 'probeNehmerId', raimund@548: fieldLabel: 'Probennehmer', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: }, { raimund@548: xtype: 'netzbetreiber', raimund@548: name: 'netzbetreiberId', raimund@548: editable: false, raimund@548: fieldLabel: 'Netzbetreiber', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: allowBlank: false, raimund@548: }, { raimund@548: xtype: 'tfield', raimund@548: name: 'x11', raimund@548: fieldLabel: 'Datensatzerzeuger', dustin@623: anchor: '100%', dustin@623: labelWidth: 105, raimund@548: }] raimund@548: }] raimund@548: }] raimund@548: }, { raimund@548: // Medium raimund@548: xtype: 'fieldset', raimund@548: title: 'Medium', raimund@548: items: [{ raimund@548: border: 0, raimund@548: layout: { raimund@548: type: 'vbox', raimund@548: align: 'stretch' raimund@548: }, raimund@548: width: '100%', raimund@548: items: [{ raimund@548: xtype: 'textfield', raimund@548: name: 'media', raimund@548: labelWidth: 125, raimund@548: fieldLabel: 'Medienbezeichnung', raimund@548: listeners: { raimund@548: dirtychange: { raimund@548: fn: this.updateOnChange, raimund@548: scope: me raimund@548: } raimund@548: } raimund@548: }, { raimund@548: xtype: 'textfield', dustin@671: maxLength: 38, dustin@671: enforceMaxLength: true, raimund@548: name: 'mediaDesk', raimund@548: labelWidth: 125, raimund@548: fieldLabel: 'Deskriptoren', dustin@671: regex: new RegExp('(?:D: ){1}(?:[0-9]{2} ){11}[0-9]{2}'), dustin@671: regexText: 'Die Deskriptoren haben das falsche Format.
'+ dustin@671: 'Richtig wäre: D: 99 99 99 99 99 99 99 99 99 99 99 99', raimund@548: listeners: { raimund@548: dirtychange: { raimund@548: fn: this.updateOnChange, raimund@548: scope: me raimund@548: } raimund@548: } raimund@548: }, { raimund@548: xtype: 'umwelt', raimund@548: name: 'umwId', raimund@548: fieldLabel: 'Umweltbereich', raimund@548: labelWidth: 125, raimund@548: allowBlank: false, raimund@548: listeners: { raimund@548: dirtychange: { raimund@548: fn: this.updateOnChange, raimund@548: scope: me raimund@548: } raimund@548: } raimund@548: }, { raimund@548: xtype: 'fieldset', raimund@548: title: 'Details Deskriptoren', raimund@548: collapsible: true, raimund@548: collapsed: true, raimund@548: defaultType: 'textfield', raimund@548: layout: { raimund@548: type: 'table', raimund@548: columns: 3 raimund@548: }, raimund@548: items: this.buildDescriptors(), raimund@548: listeners: { raimund@548: dirtychange: { raimund@548: fn: this.updateOnChange, raimund@548: scope: me raimund@548: } raimund@548: } raimund@548: }] raimund@548: }] raimund@548: }, { raimund@548: // Zeit raimund@548: xtype: 'fieldset', raimund@548: title: 'Zeit', raimund@548: layout: { dustin@646: type: 'hbox', dustin@646: pack: 'center', dustin@646: align: 'stretch' raimund@548: }, raimund@548: items: [{ dustin@646: xtype: 'fieldset', dustin@646: title: 'Probenentnahme', dustin@646: anchor: '100%', dustin@646: width: '50%', dustin@646: margin: '0, 5, 5, 5', raimund@548: layout: { raimund@548: type: 'vbox', raimund@548: align: 'stretch' raimund@548: }, raimund@548: items: [{ raimund@650: xtype: 'datetime', dustin@646: fieldLabel: 'Beginn', dustin@646: labelWidth: 90, dustin@646: anchor: '100%', raimund@548: name: 'probeentnahmeBeginn', raimund@650: format: 'd.m.Y H:i' raimund@548: }, { raimund@650: xtype: 'datetime', dustin@646: fieldLabel: 'Ende', dustin@646: labelWidth: 90, dustin@646: anchor: '100%', raimund@548: name: 'probeentnahmeEnde', raimund@650: format: 'd.m.Y H:i' raimund@548: }] raimund@548: }, { dustin@646: xtype: 'fieldset', dustin@646: title: 'Sollzeitraum', dustin@646: anchor: '100%', dustin@646: width: '50%', dustin@646: margin: '0, 5, 5, 5', dustin@646: layout: { dustin@646: type: 'vbox', raimund@650: align: 'stretch' dustin@646: }, raimund@548: items: [{ raimund@650: xtype: 'datetime', dustin@646: fieldLabel: 'Von', raimund@548: labelWidth: 90, dustin@646: anchor: '100%', raimund@548: name: 'solldatumBeginn', raimund@650: format: 'd.m.Y H:i' raimund@650: }, { raimund@650: xtype: 'datetime', dustin@646: fieldLabel: 'Bis', raimund@548: labelWidth: 90, dustin@646: anchor: '100%', raimund@548: name: 'solldatumEnde', raimund@650: format: 'd.m.Y H:i' raimund@548: }] raimund@548: }] raimund@548: }] raimund@548: }] raimund@548: }]; dustin@681: this.callParent(arguments); raimund@548: }, raimund@548: raimund@548: setRecord: function(record) { raimund@548: this.getForm().loadRecord(record); raimund@548: }, raimund@548: raimund@548: setMessages: function(errors, warnings) { raimund@548: var key; raimund@548: var element; raimund@548: var content; raimund@548: var i18n = Lada.getApplication().bundle; raimund@548: if (warnings) { raimund@548: for (key in warnings) { raimund@548: element = this.down('component[name=' + key + ']'); raimund@548: if (!element) { raimund@548: continue; raimund@548: } raimund@548: content = warnings[key]; raimund@548: var warnText = ''; raimund@548: for (var i = 0; i < content.length; i++) { raimund@548: warnText += i18n.getMsg(content[i].toString()) + '\n'; raimund@548: } raimund@548: element.showWarnings(warnText); raimund@548: } raimund@548: } raimund@548: if (errors) { raimund@548: for (key in errors) { raimund@548: element = this.down('component[name=' + key + ']'); raimund@548: if (!element) { raimund@548: continue; raimund@548: } raimund@548: content = errors[key]; raimund@548: var errorText = ''; raimund@548: for (var i = 0; i < content.length; i++) { raimund@548: errorText += i18n.getMsg(content[i].toString()) + '\n'; raimund@548: } raimund@548: element.showErrors(errorText); raimund@548: } raimund@548: } raimund@548: }, raimund@548: raimund@548: clearMessages: function() { raimund@548: this.down('cbox[name=mstId]').clearWarningOrError(); raimund@548: this.down('tfield[name=hauptprobenNr]').clearWarningOrError(); raimund@548: this.down('cbox[name=datenbasisId]').clearWarningOrError(); raimund@548: this.down('cbox[name=baId]').clearWarningOrError(); raimund@548: this.down('cbox[name=test]').clearWarningOrError(); raimund@548: this.down('cbox[name=probenartId]').clearWarningOrError(); raimund@548: this.down('cbox[name=netzbetreiberId]').clearWarningOrError(); raimund@548: this.down('tfield[name=x11]').clearWarningOrError(); raimund@548: this.down('cbox[name=umwId]').clearWarningOrError(); raimund@652: this.down('datetime[name=probeentnahmeBeginn]').clearWarningOrError(); raimund@652: this.down('datetime[name=probeentnahmeEnde]').clearWarningOrError(); raimund@652: this.down('datetime[name=solldatumBeginn]').clearWarningOrError(); raimund@652: this.down('datetime[name=solldatumEnde]').clearWarningOrError(); dustin@681: //this.down('numberfield[name=probeNehmerId]').clearWarningOrError(); raimund@548: }, raimund@548: raimund@548: setReadOnly: function(value) { raimund@548: this.down('cbox[name=mstId]').setReadOnly(value); raimund@548: this.down('tfield[name=hauptprobenNr]').setReadOnly(value); raimund@548: this.down('cbox[name=datenbasisId]').setReadOnly(value); raimund@548: this.down('cbox[name=baId]').setReadOnly(value); raimund@548: this.down('cbox[name=test]').setReadOnly(value); raimund@548: this.down('cbox[name=probenartId]').setReadOnly(value); raimund@548: this.down('cbox[name=netzbetreiberId]').setReadOnly(value); raimund@548: this.down('tfield[name=x11]').setReadOnly(value); raimund@548: this.down('textfield[name=media]').setReadOnly(value); raimund@548: this.down('textfield[name=mediaDesk]').setReadOnly(value); raimund@548: this.down('cbox[name=umwId]').setReadOnly(value); raimund@652: this.down('datetime[name=probeentnahmeBeginn]').setReadOnly(value); raimund@652: this.down('datetime[name=probeentnahmeEnde]').setReadOnly(value); raimund@652: this.down('datetime[name=solldatumBeginn]').setReadOnly(value); raimund@652: this.down('datetime[name=solldatumEnde]').setReadOnly(value); dustin@681: this.down('numberfield[name=probeNehmerId]').setReadOnly(value); raimund@548: }, raimund@548: raimund@548: buildDescriptors: function() { raimund@548: var fields = []; dustin@681: var ro = false; dustin@681: if (this.readonly) { dustin@681: ro = true; dustin@681: } raimund@548: for (var i = 0; i < 12; i++) { raimund@548: fields[i] = { raimund@548: fieldLabel: 'S' + i, raimund@548: name: 's' + i, raimund@548: labelWidth: 25, dustin@681: margin: '0, 10, 5, 0', dustin@681: readOnly: ro raimund@548: }; raimund@548: } raimund@548: return fields; raimund@548: } raimund@548: });