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: mstanko@924: /* mstanko@924: * 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', mstanko@924: 'Lada.view.widget.base.CheckBox', raimund@555: 'Lada.view.widget.Messstelle', raimund@548: 'Lada.view.widget.Netzbetreiber', raimund@548: 'Lada.view.widget.Betriebsart', raimund@548: 'Lada.view.widget.Probenart', raimund@548: 'Lada.view.widget.Umwelt', raimund@771: 'Lada.view.widget.Deskriptor', 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', raimund@771: '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: [{ mstanko@924: layout: 'vbox', raimund@548: border: 0, raimund@548: items: [{ mstanko@924: layout: { mstanko@924: type: 'hbox', mstanko@924: align: 'stretch' mstanko@924: }, mstanko@924: border: 0, mstanko@924: width: '100%', raimund@548: items: [{ mstanko@924: xtype: 'messstelle', mstanko@924: name: 'mstId', mstanko@924: fieldLabel: 'Messstelle', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', mstanko@924: labelWidth: 90, mstanko@924: allowBlank: false, mstanko@924: editable: true raimund@548: }, { raimund@548: xtype: 'netzbetreiber', raimund@548: name: 'netzbetreiberId', raimund@548: editable: false, dustin@847: readOnly: true, raimund@548: fieldLabel: 'Netzbetreiber', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', mstanko@924: labelWidth: 80, mstanko@924: allowBlank: false mstanko@924: }, { mstanko@924: xtype: 'datenbasis', mstanko@924: editable: false, mstanko@924: name: 'datenbasisId', mstanko@924: fieldLabel: 'Datenbasis', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '20%', mstanko@924: labelWidth: 65 mstanko@924: }, { mstanko@924: xtype: 'chkbox', mstanko@924: name: 'test', mstanko@924: fieldLabel: 'Test', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '10%', dustin@623: anchor: '100%', mstanko@924: labelWidth: 30 mstanko@924: }] mstanko@924: }, { mstanko@924: layout: { mstanko@924: type: 'hbox', mstanko@924: align: 'stretch' mstanko@924: }, mstanko@924: border: 0, mstanko@924: width: '100%', mstanko@924: items: [{ mstanko@924: xtype: 'tfield', mstanko@924: name: 'hauptprobenNr', mstanko@924: fieldLabel: 'Hauptprobennr.', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', mstanko@924: labelWidth: 90, mstanko@924: maxLength: 20, mstanko@924: allowBlank: true mstanko@924: }, { mstanko@924: xtype: 'betriebsart', mstanko@924: name: 'baId', mstanko@924: fieldLabel: 'Messregime', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', mstanko@924: labelWidth: 80 mstanko@924: }, { mstanko@924: xtype: 'probenart', mstanko@924: editable: false, mstanko@924: name: 'probenartId', mstanko@924: fieldLabel: 'Probenart', mstanko@924: margin: '0, 15, 5, 5', mstanko@924: width: '20%', mstanko@924: labelWidth: 65, dustin@718: allowBlank: false mstanko@924: }] mstanko@924: }, { mstanko@924: layout: { mstanko@924: type: 'hbox', mstanko@924: align: 'stretch' mstanko@924: }, mstanko@924: border: 0, mstanko@924: width: '100%', mstanko@924: items: [{ mstanko@924: xtype: 'numberfield', mstanko@924: allowDecimals: false, mstanko@924: name: 'probeNehmerId', mstanko@924: fieldLabel: 'Probennehmer', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '50%', mstanko@924: minValue: 0, mstanko@924: anchor: '100%', mstanko@924: labelWidth: 90 raimund@548: }, { raimund@548: xtype: 'tfield', raimund@548: name: 'x11', raimund@548: fieldLabel: 'Datensatzerzeuger', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '50%', dustin@623: anchor: '100%', mstanko@924: labelWidth: 90 raimund@548: }] raimund@548: }] raimund@548: }, { raimund@548: // Zeit raimund@548: xtype: 'fieldset', raimund@548: title: 'Zeit', raimund@548: layout: { mstanko@924: type: 'vbox', dustin@646: align: 'stretch' raimund@548: }, raimund@548: items: [{ dustin@717: xtype: 'fset', mstanko@924: name: 'sollzeitPeriod', mstanko@924: width: '100%', mstanko@924: border: 0, mstanko@924: margin: 0, raimund@548: layout: { mstanko@924: type: 'hbox', raimund@548: }, raimund@548: items: [{ raimund@650: xtype: 'datetime', raimund@926: emptyText: ' ', mstanko@924: fieldLabel: 'Sollzeitraum von', mstanko@924: labelWidth: 120, mstanko@924: margin: '0, 5, 5, 5', mstanko@924: name: 'solldatumBeginn', mstanko@924: format: 'd.m.Y H:i', raimund@926: period: 'start', raimund@926: readOnly: true mstanko@924: }, { mstanko@924: xtype: 'datetime', raimund@926: emptyText: ' ', mstanko@924: fieldLabel: 'bis', mstanko@924: labelWidth: 10, mstanko@924: margin: '0, 5, 5, 5', mstanko@924: name: 'solldatumEnde', mstanko@924: format: 'd.m.Y H:i', raimund@926: period: 'end', raimund@926: readOnly: true mstanko@924: }] mstanko@924: }, { mstanko@924: xtype: 'fset', mstanko@924: name: 'entnahmePeriod', mstanko@924: width: '100%', mstanko@924: border: 0, mstanko@924: margin: 0, mstanko@924: layout: { mstanko@924: type: 'hbox', mstanko@924: }, mstanko@924: items: [{ mstanko@924: xtype: 'datetime', mstanko@924: fieldLabel: 'Probenentnahme von', mstanko@924: labelWidth: 120, mstanko@924: margin: '0, 5, 5, 5', raimund@548: name: 'probeentnahmeBeginn', dustin@717: format: 'd.m.Y H:i', dustin@717: period: 'start' raimund@548: }, { raimund@650: xtype: 'datetime', mstanko@924: fieldLabel: 'bis', mstanko@924: labelWidth: 10, mstanko@924: margin: '0, 5, 5, 5', raimund@548: name: 'probeentnahmeEnde', dustin@717: format: 'd.m.Y H:i', dustin@717: period: 'end' raimund@548: }] raimund@548: }] dustin@838: }, { dustin@838: // Medium dustin@838: xtype: 'fieldset', dustin@838: title: 'Medium', mstanko@924: width: '100%', dustin@838: items: [{ dustin@838: border: 0, dustin@838: layout: { dustin@838: type: 'vbox', dustin@838: align: 'stretch' dustin@838: }, dustin@838: width: '100%', dustin@838: items: [{ dustin@838: xtype: 'umwelt', dustin@838: name: 'umwId', dustin@838: fieldLabel: 'Umweltbereich', dustin@838: labelWidth: 125, dustin@838: allowBlank: false, dustin@838: editable: true, dustin@838: listeners: { dustin@838: dirtychange: { dustin@838: fn: this.updateOnChange, dustin@838: scope: me dustin@838: } dustin@838: } dustin@838: }, { mstanko@924: border: 0, mstanko@924: layout: { mstanko@924: type: 'hbox', mstanko@924: align: 'stretch' mstanko@924: }, mstanko@924: width: '100%', mstanko@924: items: [{ mstanko@924: xtype: 'tfield', mstanko@924: maxLength: 38, mstanko@924: enforceMaxLength: true, mstanko@924: name: 'mediaDesk', mstanko@924: width: '60%', mstanko@924: minWidth: 290, mstanko@924: labelWidth: 125, mstanko@924: fieldLabel: 'Deskriptoren', mstanko@924: regex: new RegExp('(?:D: ){1}(?:[0-9]{2} ){11}[0-9]{2}'), mstanko@924: regexText: 'Die Deskriptoren haben das falsche Format.
'+ mstanko@924: 'Richtig wäre: D: 99 99 99 99 99 99 99 99 99 99 99 99', mstanko@924: listeners: { mstanko@924: dirtychange: { mstanko@924: fn: this.updateOnChange, mstanko@924: scope: me mstanko@924: } mstanko@924: } mstanko@924: }, { mstanko@924: xtype: 'textfield', mstanko@924: name: 'media', mstanko@924: margin: '0, 10, 5, 10', mstanko@924: enforceMaxLength: true, mstanko@924: editable: false, mstanko@924: readOnly: true, mstanko@924: listeners: { mstanko@924: dirtychange: { mstanko@924: fn: this.updateOnChange, mstanko@924: scope: me mstanko@924: } mstanko@924: } mstanko@924: }] mstanko@924: }, { dustin@838: xtype: 'fieldset', dustin@838: title: 'Details Deskriptoren', dustin@838: collapsible: true, dustin@838: collapsed: true, dustin@838: layout: { dustin@838: type: 'table', dustin@838: columns: 3 dustin@838: }, dustin@838: items: this.buildDescriptors() dustin@838: }] dustin@838: }] raimund@548: }] raimund@548: }] raimund@548: }]; dustin@681: this.callParent(arguments); dustin@816: this.clearMessages(); raimund@548: }, raimund@548: raimund@548: setRecord: function(record) { dustin@717: this.clearMessages(); raimund@548: this.getForm().loadRecord(record); raimund@548: }, raimund@548: raimund@771: setMediaDesk: function(record) { raimund@771: var media = record.get('mediaDesk').split(' '); raimund@771: this.setMediaSN(0, media); raimund@771: }, raimund@771: raimund@771: setMediaSN: function(ndx, media) { raimund@771: if (ndx >= 12) { raimund@771: return; raimund@771: } raimund@771: var me = this; raimund@771: var current = this.down('deskriptor[layer=' + ndx + ']'); raimund@771: var cbox = current.down('combobox'); raimund@771: if (ndx === 0) { raimund@771: cbox.store.proxy.extraParams = { raimund@771: 'layer': ndx raimund@771: }; raimund@771: } raimund@771: else { raimund@771: var parents = current.getParents(current.down('combobox')); raimund@771: if (parents.length === 0) { raimund@771: return; raimund@771: } raimund@771: cbox.store.proxy.extraParams = { raimund@771: 'layer': ndx, raimund@771: 'parents': parents raimund@771: }; raimund@771: } raimund@771: cbox.store.load(function(records, op, success) { raimund@771: if (!success) { raimund@771: return; raimund@771: } raimund@771: cbox.select(cbox.store.findRecord('sn', parseInt(media[ndx + 1], 10))); raimund@771: me.setMediaSN(++ndx, media); raimund@771: }); raimund@771: }, raimund@771: 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(); mstanko@924: this.down('chkbox[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(); dustin@717: this.down('fset[name=entnahmePeriod]').clearMessages(); dustin@717: this.down('fset[name=sollzeitPeriod]').clearMessages(); 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); mstanko@924: this.down('chkbox[name=test]').setReadOnly(value); raimund@548: this.down('cbox[name=probenartId]').setReadOnly(value); dustin@847: //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@783: this.down('tfield[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); dustin@681: this.down('numberfield[name=probeNehmerId]').setReadOnly(value); dustin@685: dustin@685: //Deskriptoren dustin@685: for (var i = 0; i < 12; i++) { raimund@783: this.down('deskriptor[layer='+i+']').setReadOnly(value); dustin@685: } raimund@548: }, raimund@548: raimund@548: buildDescriptors: function() { raimund@548: var fields = []; raimund@548: for (var i = 0; i < 12; i++) { raimund@548: fields[i] = { raimund@771: xtype: 'deskriptor', raimund@548: fieldLabel: 'S' + i, raimund@783: //name: 's' + i, raimund@548: labelWidth: 25, raimund@771: width: 190, raimund@771: layer: i, dustin@718: margin: '0, 10, 5, 0' raimund@548: }; raimund@548: } raimund@548: return fields; raimund@548: } raimund@548: });