diff app/view/form/Messprogramm.js @ 784:f0b26df02157

Handle deskriptoren in messprogramm like in probe.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 13 May 2015 10:23:39 +0200
parents 3309db91b8c1
children 442e7bd290dc
line wrap: on
line diff
--- a/app/view/form/Messprogramm.js	Wed May 13 10:22:53 2015 +0200
+++ b/app/view/form/Messprogramm.js	Wed May 13 10:23:39 2015 +0200
@@ -399,7 +399,42 @@
             Lada.app.getController('Lada.controller.form.Messprogramm')
                 .synchronizeFields
         );
+    },
 
+    setMediaDesk: function(record) {
+        var media = record.get('mediaDesk').split(' ');
+        this.setMediaSN(0, media);
+    },
+
+    setMediaSN: function(ndx, media) {
+        if (ndx >= 12) {
+            return;
+        }
+        var me = this;
+        var current = this.down('deskriptor[layer=' + ndx + ']');
+        var cbox = current.down('combobox');
+        if (ndx === 0) {
+            cbox.store.proxy.extraParams = {
+                'layer': ndx
+            };
+        }
+        else {
+            var parents = current.getParents(current.down('combobox'));
+            if (parents.length === 0) {
+                return;
+            }
+            cbox.store.proxy.extraParams = {
+                'layer': ndx,
+                'parents': parents
+            };
+        }
+        cbox.store.load(function(records, op, success) {
+            if (!success) {
+                return;
+            }
+            cbox.select(cbox.store.findRecord('sn', parseInt(media[ndx + 1], 10)));
+            me.setMediaSN(++ndx, media);
+        });
     },
 
     setMessages: function(errors, warnings) {
@@ -463,9 +498,11 @@
         var fields = [];
         for (var i = 0; i < 12; i++) {
             fields[i] = {
+                xtype: 'deskriptor',
                 fieldLabel: 'S' + i,
-                name: 's' + i,
                 labelWidth: 25,
+                width: 190,
+                layer: i,
                 margin: '0, 10, 5, 0'
             };
         }

http://lada.wald.intevation.org