changeset 1067:3da8e8b973ad

Use the laborMstId to generate probe objects.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 14 Mar 2016 10:16:22 +0100
parents d198946e5540
children 096d552508cd
files app/model/Messprogramm.js app/view/form/Messprogramm.js
diffstat 2 files changed, 76 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/app/model/Messprogramm.js	Fri Mar 11 13:58:04 2016 +0100
+++ b/app/model/Messprogramm.js	Mon Mar 14 10:16:22 2016 +0100
@@ -29,6 +29,8 @@
     }, {
         name: 'mstId'
     }, {
+        name: 'laborMstId'
+    }, {
         name: 'name'
     }, {
         name: 'datenbasisId'
--- a/app/view/form/Messprogramm.js	Fri Mar 11 13:58:04 2016 +0100
+++ b/app/view/form/Messprogramm.js	Mon Mar 14 10:16:22 2016 +0100
@@ -86,12 +86,44 @@
                         },
                         margin: '0, 10, 0, 0',
                         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: i18n.getMsg('mstId'),
-                            labelWidth: 135,
+                            fieldLabel: 'Messstelle/Labor',
+                            margin: '0, 5, 5, 5',
+                            width: '35%',
+                            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: 'tfield',
                             name: 'name',
@@ -401,24 +433,58 @@
         i.setMaxValue(max-1);
     },
 
-    setRecord: function(record) {
+    setRecord: function(messRecord) {
         this.clearMessages();
 
-        this.getForm().loadRecord(record);
+        this.getForm().loadRecord(messRecord);
         //Set the intervall numberfields and the slider.
         this.down('probenintervallslider').setValue([
-            record.get('teilintervallVon'),
-            record.get('teilintervallBis')
+            messRecord.get('teilintervallVon'),
+            messRecord.get('teilintervallBis')
         ]);
 
         //TODO Set Sliders MinMaxValue
-        this.populateIntervall(record);
+        this.populateIntervall(messRecord);
 
         this.down('probenintervallslider').on(
             'change',
             Lada.app.getController('Lada.controller.form.Messprogramm')
                 .synchronizeFields
         );
+        var mstStore = Ext.data.StoreManager.get('messstellen');
+        if (!messRecord.get('owner')) {
+            var mstId = mstStore.getById(messRecord.get('mstId'));
+            var laborMstId = mstStore.getById(messRecord.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: messRecord.get('laborMstId'),
+                    messStelle: messRecord.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') === messRecord.get('mstId') &&
+                    record.get('laborMst') === messRecord.get('laborMstId')) {
+                    return true;
+                }
+            });
+            this.down('messstellelabor').setValue(items.getAt(0));
+        }
     },
 
     setMediaDesk: function(record) {

http://lada.wald.intevation.org