diff app/controller/form/Probe.js @ 776:da14e0f3e599

merged
author Dustin Demuth <dustin@intevation.de>
date Tue, 12 May 2015 16:26:05 +0200
parents dd6925ef6028
children ff4330d4aba1
line wrap: on
line diff
--- a/app/controller/form/Probe.js	Tue May 12 16:25:17 2015 +0200
+++ b/app/controller/form/Probe.js	Tue May 12 16:26:05 2015 +0200
@@ -29,6 +29,9 @@
             },
             'probeform [xtype="datetime"] field': {
                 blur: this.checkDate
+            },
+            'probeform panel[xtype="deskriptor] combobox': {
+                select: this.deskriptorSelect
             }
         });
     },
@@ -173,5 +176,52 @@
         if (w == 0 && e == 0) {
             field.up().clearWarningOrError();
         }
+    },
+
+    deskriptorSelect: function(field, records) {
+        var desk = field.up('deskriptor');
+        var media = field.up('probeform').down('textfield[name="mediaDesk"]');
+        var current = media.getValue().split(' ');
+        this.clearChildDesk(field.up('deskriptor'), current);
+        if (current.length < 13) {
+            for (var i = 0; i <= 12; i++) {
+                if (i === 0) {
+                    current.push('D:');
+                }
+                else if (i === desk.layer + 1) {
+                    var value;
+                    if (records[0].get('sn') < 10) {
+                        value = '0' + records[0].get('sn');
+                    }
+                    else {
+                        value = records[0].get('sn');
+                    }
+                    current.push(value);
+                }
+                else {
+                    current.push('00');
+                }
+            }
+        }
+        else {
+            var value;
+            if (records[0].get('sn') < 10) {
+                value = '0' + records[0].get('sn');
+            }
+            else {
+                value = records[0].get('sn');
+            }
+            current[desk.layer + 1] = value;
+        }
+        media.setValue(current.join(' ').trim());
+    },
+
+    clearChildDesk: function(field, media) {
+        var allS = field.up('fieldset').items.items;
+        for (var i = field.layer + 1; i < 12; i++) {
+            allS[i].clearValue();
+            media[i + 1] = '00';
+        }
     }
+
 });

http://lada.wald.intevation.org