changeset 1066:d198946e5540

Introduced laborMstId as new probe field.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 11 Mar 2016 13:58:04 +0100
parents 7fa853864d9b
children 3da8e8b973ad
files app.js app/controller/form/Probe.js app/model/MessstelleLabor.js app/model/Probe.js app/view/form/Probe.js app/view/widget/MessstelleLabor.js
diffstat 6 files changed, 176 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Thu Mar 10 10:45:50 2016 +0100
+++ b/app.js	Fri Mar 11 13:58:04 2016 +0100
@@ -52,7 +52,8 @@
         'Lada.store.Umwelt',
         'Lada.store.Verwaltungseinheiten',
         'Lada.store.StatusWerte',
-        'Lada.store.StatusStufe'
+        'Lada.store.StatusStufe',
+        'Lada.model.MessstelleLabor'
     ],
     bundle: {
         bundle: 'Lada',
@@ -114,16 +115,25 @@
     },
 
     onLoginSuccess: function(response) {
-
         /* Parse Username and Timestamp */
         var json = Ext.decode(response.responseText);
         Lada.username = json.data.username;
         Lada.userroles = json.data.roles;
         Lada.logintime = json.data.servertime;
-        Lada.mst = json.data.mst; //Store Messstellen this user may select
+        Lada.mst = []; //Store Messstellen this user may select
         Lada.funktionen = json.data.funktionen;
         //Lada.serverVersion
         this.getServerVersion();
+        var mstLabor = json.data.messstelleLabor;
+        for (var i = 0; i < mstLabor.length; i++) {
+            Lada.mst.push(mstLabor[i].messstelle);
+            Lada.mst.push(mstLabor[i].labor);
+        }
+
+        var mstLaborStore = Ext.create('Ext.data.Store', {
+            storeId: 'messstellelabor',
+            model: 'Lada.model.MessstelleLabor'
+        });
 
         Ext.create('Lada.store.Datenbasis', {
             storeId: 'datenbasis'
@@ -138,7 +148,25 @@
             storeId: 'messmethoden'
         });
         Ext.create('Lada.store.Messstellen', {
-            storeId: 'messstellen'
+            storeId: 'messstellen',
+            listeners: {
+                load: {
+                    fn: function(store, records) {
+                        for (var i = 0; i < mstLabor.length; i++) {
+                            var item = store.getById(mstLabor[i].messstelle);
+                            var itemLabor = store.getById(mstLabor[i].labor);
+                            mstLaborStore.add({
+                                id: i,
+                                messStelle: mstLabor[i].messstelle,
+                                netzbetreiberId: item.get('netzbetreiberId'),
+                                laborMst: mstLabor[i].labor,
+                                displayCombi: item.get('messStelle') +
+                                    '/' + itemLabor.get('messStelle')
+                            });
+                        }
+                    }
+                }
+            }
         });
         Ext.create('Lada.store.Netzbetreiber', {
             storeId: 'netzbetreiber'
--- a/app/controller/form/Probe.js	Thu Mar 10 10:45:50 2016 +0100
+++ b/app/controller/form/Probe.js	Fri Mar 11 13:58:04 2016 +0100
@@ -27,9 +27,7 @@
             'probeform': {
                 dirtychange: this.dirtyForm
             },
-            'probeform messstelle combobox': {
-                expand: this.filter,
-                keydown: this.filter,
+            'probeform messstellelabor combobox': {
                 select: this.setNetzbetreiber
             },
             'probeform [xtype="datetime"] field': {
@@ -155,11 +153,9 @@
         formPanel.down('fset[name=sollzeitPeriod]').clearMessages();
         formPanel.down('datetime[name=probeentnahmeBeginn]').clearWarningOrError();
         formPanel.down('datetime[name=probeentnahmeEnde]').clearWarningOrError();
-        formPanel.down('datetime[name=solldatumBeginn]').clearWarningOrError();
-        formPanel.down('datetime[name=solldatumEnde]').clearWarningOrError();
 
         formPanel.down('umwelt').store.clearFilter();
-        formPanel.getForm().loadRecord(formPanel.getForm().getRecord());
+        formPanel.setRecord(formPanel.getForm().getRecord());
     },
 
      /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/model/MessstelleLabor.js	Fri Mar 11 13:58:04 2016 +0100
@@ -0,0 +1,32 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Model for Messstelle Stammdaten.
+ */
+Ext.define('Lada.model.MessstelleLabor', {
+    extend: 'Ext.data.Model',
+
+    /**
+     * Fields are:
+     *  - id: The unique identifier (Primary key).
+     *  - messStelle
+     *  - laborMst
+     */
+    fields: [{
+        name: 'id'
+    }, {
+        name: 'messStelle'
+    }, {
+        name: 'laborMst'
+    }, {
+        name: 'netzbetreiberId'
+    }, {
+        name: 'displayCombi'
+    }]
+});
--- a/app/model/Probe.js	Thu Mar 10 10:45:50 2016 +0100
+++ b/app/model/Probe.js	Fri Mar 11 13:58:04 2016 +0100
@@ -37,6 +37,8 @@
     }, {
         name: 'mstId'
     }, {
+        name: 'laborMstId'
+    }, {
         name: 'datenbasisId'
     }, {
         name: 'baId'
--- a/app/view/form/Probe.js	Thu Mar 10 10:45:50 2016 +0100
+++ b/app/view/form/Probe.js	Fri Mar 11 13:58:04 2016 +0100
@@ -15,7 +15,7 @@
     requires: [
         'Lada.view.widget.Datenbasis',
         'Lada.view.widget.base.CheckBox',
-        'Lada.view.widget.Messstelle',
+        'Lada.view.widget.MessstelleLabor',
         'Lada.view.widget.Netzbetreiber',
         'Lada.view.widget.Betriebsart',
         'Lada.view.widget.Probenart',
@@ -79,14 +79,44 @@
                             border: 0,
                             width: '100%',
                             items: [{
+                                xtype: 'messstellelabor',
+                                name: 'mstlabor',
+                                fieldLabel: 'Messstelle/Labor',
+                                margin: '0, 5, 5, 5',
+                                width: '35%',
+                                labelWidth: 95,
+                                allowBlank: false,
+                                editable: true,
+                                listeners: {
+                                    select: {
+                                        fn: function(combo, newValue) {
+                                            var mst = newValue[0].get('messStelle');
+                                            var labor = newValue[0].get('laborMst');
+                                            combo.up('fieldset').down('messstelle[name=mstId]').setValue(mst);
+                                            combo.up('fieldset').down('messstelle[name=laborMstId]').setValue(labor);
+                                        }
+                                    }
+                                }
+                            }, {
                                 xtype: 'messstelle',
                                 name: 'mstId',
-                                fieldLabel: 'Messstelle',
+                                fieldLabel: 'Messstelle/Labor',
                                 margin: '0, 5, 5, 5',
                                 width: '35%',
-                                labelWidth: 90,
+                                labelWidth: 95,
                                 allowBlank: false,
-                                editable: true
+                                editable: true,
+                                hidden: true
+                            }, {
+                                xtype: 'messstelle',
+                                name: 'laborMstId',
+                                fieldLabel: 'Messstelle/Labor',
+                                margin: '0, 5, 5, 5',
+                                width: '35%',
+                                labelWidth: 95,
+                                allowBlank: false,
+                                editable: true,
+                                hidden: true
                             }, {
                                 xtype: 'netzbetreiber',
                                 name: 'netzbetreiberId',
@@ -127,7 +157,7 @@
                                 fieldLabel: 'Hauptprobennr.',
                                 margin: '0, 5, 5, 5',
                                 width: '35%',
-                                labelWidth: 90,
+                                labelWidth: 95,
                                 maxLength: 20,
                                 allowBlank: true
                             }, {
@@ -163,7 +193,7 @@
                                 width: '50%',
                                 minValue: 0,
                                 anchor: '100%',
-                                labelWidth: 90
+                                labelWidth: 95
                             }, {
                                 xtype: 'tfield',
                                 name: 'x11',
@@ -316,9 +346,46 @@
         this.clearMessages();
     },
 
-    setRecord: function(record) {
+    setRecord: function(probeRecord) {
         this.clearMessages();
-        this.getForm().loadRecord(record);
+        this.getForm().loadRecord(probeRecord);
+        if (!probeRecord.raw) {
+            return;
+        }
+        var mstStore = Ext.data.StoreManager.get('messstellen');
+        if (!probeRecord.get('owner')) {
+            var mstId = mstStore.getById(probeRecord.get('mstId'));
+            var laborMstId = mstStore.getById(probeRecord.get('laborMstId'));
+            if (laborMstId) {
+                laborMstId = laborMstId.get('messStelle');
+            }
+            else {
+                laborMstId = '';
+            }
+            var id = this.down('messstellelabor').store.count() + 1;
+            var newStore = Ext.create('Ext.data.Store', {
+                model: 'Lada.model.MessstelleLabor',
+                data: [{
+                    id: id,
+                    laborMst: probeRecord.get('laborMstId'),
+                    messStelle: probeRecord.get('mstId'),
+                    displayCombi: mstId.get('messStelle') +
+                        '/' + laborMstId
+                }]
+            });
+            this.down('messstellelabor').down('combobox').store = newStore;
+            this.down('messstellelabor').setValue(id);
+        }
+        else {
+            var mstLaborStore = Ext.data.StoreManager.get('messstellelabor');
+            var items = mstLaborStore.queryBy(function(record) {
+                if (record.get('messStelle') === probeRecord.get('mstId') &&
+                    record.get('laborMst') === probeRecord.get('laborMstId')) {
+                    return true;
+                }
+            });
+            this.down('messstellelabor').setValue(items.getAt(0));
+        }
     },
 
     setMediaDesk: function(record) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/view/widget/MessstelleLabor.js	Fri Mar 11 13:58:04 2016 +0100
@@ -0,0 +1,33 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+/**
+ * Combobox for Messstelle
+ */
+Ext.define('Lada.view.widget.MessstelleLabor', {
+    extend: 'Lada.view.widget.base.ComboBox',
+    alias: 'widget.messstellelabor',
+    store: 'MessstelleLabor',
+    displayField: 'displayCombi',
+    valueField: 'id',
+    editable: this.editable || false,
+    forceSelection: true,
+    emptyText: 'Wählen Sie eine Kombination',
+    // Enable filtering of comboboxes
+    autoSelect: true,
+    queryMode: 'local',
+    triggerAction: 'all',
+    typeAhead: false,
+    minChars: 0,
+
+    initComponent: function() {
+        this.store = Ext.data.StoreManager.get('messstellelabor');
+        this.callParent(arguments);
+        this.down('combobox').isFormField = false;
+    }
+});

http://lada.wald.intevation.org