[Lada-commits] [PATCH] Use the laborMstId to generate probe objects

Wald Commits scm-commit at wald.intevation.org
Mon Mar 14 10:16:34 CET 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1457946982 -3600
# Node ID 3da8e8b973ad1017fd5e5efd9483a3c3f4f12a9d
# Parent  d198946e5540159d4d4d8383c28de376927690cb
Use the laborMstId to generate probe objects.

diff -r d198946e5540 -r 3da8e8b973ad app/model/Messprogramm.js
--- 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'
diff -r d198946e5540 -r 3da8e8b973ad app/view/form/Messprogramm.js
--- 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) {


More information about the Lada-commits mailing list