changeset 1210:a24de34d6423

Align subintervall with validity for yearly samples. Subintervall is redundant to validity for yearly samples.
author Tom Gottfried <tom@intevation.de>
date Tue, 11 Oct 2016 14:34:12 +0200
parents 78805e951c37
children 85b018980347
files app/controller/form/Messprogramm.js app/view/form/Messprogramm.js
diffstat 2 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/form/Messprogramm.js	Mon Oct 10 16:42:30 2016 +0200
+++ b/app/controller/form/Messprogramm.js	Tue Oct 11 14:34:12 2016 +0200
@@ -51,6 +51,9 @@
             'messprogrammform probenintervall combobox': {
                 select: this.updateIntervalls
             },
+            'messprogrammform dayofyear [hidden]': {
+                change: this.alignSubIntervall
+            },
             'messprogrammform panel[xtype="deskriptor] combobox': {
                 select: this.deskriptorSelect
             }
@@ -90,15 +93,34 @@
 
     /**
      * When the Probenintervall was changed, update the Sliders
-     * and the the numberfield.
+     * and the numberfield.
      */
-    updateIntervalls: function(field, records) {
+    updateIntervalls: function(field) {
         var form = field.up('messprogrammform');
         var record = form.getRecord();
         form.populateIntervall(record, field.getValue());
     },
 
     /**
+     * When the validity period was changed, align the subintervall
+     * in case of yearly intervall.
+     */
+    alignSubIntervall: function(field) {
+        var form = field.up('messprogrammform');
+        var intervall = form.down('probenintervall').down('combobox')
+            .getValue();
+        if (intervall == 'J') {
+            if (field.getName() == 'gueltigVon') {
+                form.down('[name=teilintervallVon]')
+                    .setValue(field.getValue());
+            } else {
+                form.down('[name=teilintervallBis]')
+                    .setValue(field.getValue());
+            }
+        }
+    },
+
+    /**
      * The function will open a new Window to edit the Ort of a Messprogramm
      */
     editOrtWindow: function(button) {
@@ -239,7 +261,7 @@
     },
 
      /**
-      * The discard function resets the Location form
+      * The discard function resets the form
       * to its original state.
       */
     discard: function(button) {
--- a/app/view/form/Messprogramm.js	Mon Oct 10 16:42:30 2016 +0200
+++ b/app/view/form/Messprogramm.js	Tue Oct 11 14:34:12 2016 +0200
@@ -433,6 +433,18 @@
             svalLower = record.get('teilintervallVon');
         }
 
+        // subintervall is redundant to validity for yearly samples
+        if (intervall == 'J') {
+            svalUpper = this.getForm().findField('gueltigBis').getValue();
+            svalLower = this.getForm().findField('gueltigVon').getValue();
+            b.setReadOnly(true);
+            v.setReadOnly(true);
+            s.setDisabled(true);
+        } else {
+            b.setReadOnly(false);
+            v.setReadOnly(false);
+            s.setDisabled(false);
+        }
 
         var intrec = intervallstore
             .findRecord('probenintervall',

http://lada.wald.intevation.org