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@1107: 'Lada.view.widget.DatensatzErzeuger', mstanko@1107: 'Lada.view.widget.Probenehmer', mstanko@1107: 'Lada.view.widget.MessprogrammLand', mstanko@924: 'Lada.view.widget.base.CheckBox', raimund@1066: 'Lada.view.widget.MessstelleLabor', 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', tom@1189: 'Lada.view.window.MessungCreate', 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; tom@1155: var i18n = Lada.getApplication().bundle; 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@1386: text: i18n.getMsg('audittrail'), raimund@1386: qtip: i18n.getMsg('qtip.audit'), raimund@1386: icon: 'resources/img/distribute-vertical-center.png', raimund@1386: action: 'audit', raimund@1386: disabled: this.recordId === null raimund@1386: }, { 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, ehuber@1175: items: [{ ehuber@1175: xtype: 'displayfield', ehuber@1243: name: 'idAlt', ehuber@1175: fieldLabel: i18n.getMsg('probeId'), ehuber@1175: margin: '0, 5, 5, 5', ehuber@1175: labelWidth: 95, ehuber@1175: maxLength: 20 ehuber@1175: },{ mstanko@924: layout: { mstanko@924: type: 'hbox', mstanko@924: align: 'stretch' mstanko@924: }, mstanko@924: border: 0, mstanko@924: width: '100%', raimund@548: items: [{ raimund@1066: xtype: 'messstellelabor', raimund@1066: name: 'mstlabor', raimund@1066: fieldLabel: 'Messstelle/Labor', raimund@1066: margin: '0, 5, 5, 5', raimund@1066: width: '35%', raimund@1066: labelWidth: 95, raimund@1066: allowBlank: false, raimund@1066: editable: true, raimund@1066: listeners: { raimund@1066: select: { raimund@1066: fn: function(combo, newValue) { raimund@1066: var mst = newValue[0].get('messStelle'); raimund@1066: var labor = newValue[0].get('laborMst'); raimund@1066: combo.up('fieldset').down('messstelle[name=mstId]').setValue(mst); raimund@1066: combo.up('fieldset').down('messstelle[name=laborMstId]').setValue(labor); ehuber@1396: combo.up('fieldset').down('messprogrammland[name=mplId]').setValue(); raimund@1066: } raimund@1066: } raimund@1066: } raimund@1066: }, { mstanko@924: xtype: 'messstelle', mstanko@924: name: 'mstId', raimund@1066: fieldLabel: 'Messstelle/Labor', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', raimund@1066: labelWidth: 95, mstanko@924: allowBlank: false, raimund@1066: editable: true, raimund@1066: hidden: true raimund@1066: }, { raimund@1066: xtype: 'messstelle', raimund@1066: name: 'laborMstId', raimund@1066: fieldLabel: 'Messstelle/Labor', raimund@1066: margin: '0, 5, 5, 5', raimund@1066: width: '35%', raimund@1066: labelWidth: 95, raimund@1066: allowBlank: false, raimund@1066: editable: true, raimund@1066: hidden: true raimund@548: }, { raimund@548: xtype: 'netzbetreiber', ehuber@1396: name: 'netzbetreiber', raimund@548: editable: false, dustin@847: readOnly: true, tom@1217: isFormField: false, tom@1217: submitValue: false, tom@1235: fieldLabel: i18n.getMsg('netzbetreiberId'), mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', tom@1235: labelWidth: 80 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', tom@1155: fieldLabel: i18n.getMsg('hauptprobenNr'), mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '35%', raimund@1066: labelWidth: 95, 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@1107: xtype: 'probenehmer', 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%', raimund@1066: labelWidth: 95 raimund@548: }, { mstanko@1107: xtype: 'datensatzerzeuger', mstanko@1107: name: 'erzeugerId', raimund@548: fieldLabel: 'Datensatzerzeuger', mstanko@924: margin: '0, 5, 5, 5', mstanko@924: width: '50%', dustin@623: anchor: '100%', raimund@928: labelWidth: 110 raimund@548: }] mstanko@1107: },{ mstanko@1107: xtype: 'messprogrammland', mstanko@1107: name: 'mplId', mstanko@1107: fieldLabel: 'Messprogramm-Land', mstanko@1107: margin: '0, 5, 5, 5', mstanko@1116: width: '100%', mstanko@1107: anchor: '100%', ehuber@1396: labelWidth: 110, ehuber@1396: listeners: { ehuber@1396: expand : { ehuber@1396: fn: function(combo) { ehuber@1396: Ext.StoreManager.get('messprogrammkategorie').clearFilter(); ehuber@1396: Ext.StoreManager.get('messprogrammkategorie').filter('netzbetreiberId', combo.up('fieldset').down('netzbetreiber[name=netzbetreiber]').getValue()); ehuber@1396: } ehuber@1396: } ehuber@1396: } 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: { raimund@928: type: 'hbox' raimund@548: }, raimund@548: items: [{ mstanko@931: xtype: 'datefield', raimund@926: emptyText: ' ', mstanko@924: fieldLabel: 'Sollzeitraum von', raimund@928: labelWidth: 130, mstanko@924: margin: '0, 5, 5, 5', mstanko@924: name: 'solldatumBeginn', mstanko@931: format: 'd.m.Y', raimund@926: period: 'start', raimund@926: readOnly: true mstanko@924: }, { mstanko@931: xtype: 'datefield', raimund@926: emptyText: ' ', mstanko@924: fieldLabel: 'bis', raimund@928: labelWidth: 17, mstanko@924: margin: '0, 5, 5, 5', mstanko@924: name: 'solldatumEnde', mstanko@931: format: 'd.m.Y', 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: { raimund@928: type: 'hbox' mstanko@924: }, mstanko@924: items: [{ mstanko@924: xtype: 'datetime', mstanko@924: fieldLabel: 'Probenentnahme von', raimund@928: labelWidth: 130, 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', raimund@928: labelWidth: 17, 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', ehuber@1383: labelWidth: 100, 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', ehuber@1383: width: '58%', mstanko@924: minWidth: 290, ehuber@1383: labelWidth: 100, mstanko@924: fieldLabel: 'Deskriptoren', mstanko@930: editable: false, mstanko@930: 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: xtype: 'textfield', mstanko@924: name: 'media', mstanko@924: margin: '0, 10, 5, 10', ehuber@1383: width: '42%', mstanko@924: enforceMaxLength: true, mstanko@924: editable: false, mstanko@931: readOnly: true mstanko@924: }] mstanko@924: }, { dustin@838: xtype: 'fieldset', dustin@838: title: 'Details Deskriptoren', dustin@838: collapsible: true, dustin@838: collapsed: true, dustin@838: layout: { mstanko@930: type: 'vbox', mstanko@930: align: 'stretch' 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@1066: setRecord: function(probeRecord) { dustin@717: this.clearMessages(); raimund@1066: this.getForm().loadRecord(probeRecord); raimund@1066: if (!probeRecord.raw) { raimund@1066: return; raimund@1066: } raimund@1066: var mstStore = Ext.data.StoreManager.get('messstellen'); tom@1217: var mstId = mstStore.getById(probeRecord.get('mstId')); raimund@1066: if (!probeRecord.get('owner')) { raimund@1066: var laborMstId = mstStore.getById(probeRecord.get('laborMstId')); raimund@1066: if (laborMstId) { raimund@1066: laborMstId = laborMstId.get('messStelle'); raimund@1066: } raimund@1066: else { raimund@1066: laborMstId = ''; raimund@1066: } raimund@1066: var id = this.down('messstellelabor').store.count() + 1; raimund@1066: var newStore = Ext.create('Ext.data.Store', { raimund@1066: model: 'Lada.model.MessstelleLabor', raimund@1066: data: [{ raimund@1066: id: id, raimund@1066: laborMst: probeRecord.get('laborMstId'), raimund@1066: messStelle: probeRecord.get('mstId'), raimund@1066: displayCombi: mstId.get('messStelle') + raimund@1066: '/' + laborMstId raimund@1066: }] raimund@1066: }); raimund@1066: this.down('messstellelabor').down('combobox').store = newStore; raimund@1066: this.down('messstellelabor').setValue(id); raimund@1066: } raimund@1066: else { raimund@1066: var mstLaborStore = Ext.data.StoreManager.get('messstellelabor'); raimund@1066: var items = mstLaborStore.queryBy(function(record) { raimund@1066: if (record.get('messStelle') === probeRecord.get('mstId') && raimund@1066: record.get('laborMst') === probeRecord.get('laborMstId')) { raimund@1066: return true; raimund@1066: } raimund@1066: }); raimund@1066: this.down('messstellelabor').setValue(items.getAt(0)); raimund@1066: } tom@1217: this.down('netzbetreiber').setValue(mstId.get('netzbetreiberId')); raimund@548: }, raimund@548: raimund@771: setMediaDesk: function(record) { tom@1234: var media = record.get('mediaDesk'); tom@1234: if (media) { tom@1234: var mediaParts = media.split(' '); tom@1234: this.setMediaSN(0, mediaParts); tom@1234: } raimund@771: }, raimund@771: mstanko@1276: setMediaSN: function(ndx, media, beschreibung) { ehuber@1384: var mediabeschreibung = this.getForm().findField('media'); raimund@771: if (ndx >= 12) { mstanko@1276: mediabeschreibung.setValue(beschreibung); 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))); mstanko@1276: var mediatext = cbox.store.findRecord('sn', parseInt(media[ndx + 1], 10)); mstanko@1276: if (mediatext !== null) { mstanko@1276: if ( (ndx <= 3) && (media[1] === '01') && (mediatext.data.beschreibung !== "leer") ) { mstanko@1276: beschreibung = mediatext.data.beschreibung; mstanko@1276: } else if ( (media[1] !== '01') && (mediatext.data.beschreibung !== "leer") && (ndx <= 1) ) { mstanko@1276: beschreibung = mediatext.data.beschreibung; mstanko@1276: } mstanko@1276: } mstanko@1276: me.setMediaSN(++ndx, media, beschreibung); 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@1068: this.down('cbox[name=mstlabor]').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(); tom@1217: this.down('netzbetreiber').clearWarningOrError(); mstanko@1107: this.down('cbox[name=erzeugerId]').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(); 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@1068: this.down('cbox[name=mstlabor]').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); mstanko@1107: this.down('cbox[name=erzeugerId]').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); mstanko@1107: this.down('cbox[name=probeNehmerId]').setReadOnly(value); mstanko@1116: this.down('cbox[name=mplId]').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: });