changeset 655:195a253e9842

Fixed bug in datetimepicker: Allways insert leading zero; do not allow values bigger than maxValue.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 18 Mar 2015 17:41:05 +0100
parents e4419c5560e7
children 0c1a9d7dd1e9
files app/view/widget/base/DateTimePicker.js
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/view/widget/base/DateTimePicker.js	Wed Mar 18 15:45:15 2015 +0100
+++ b/app/view/widget/base/DateTimePicker.js	Wed Mar 18 17:41:05 2015 +0100
@@ -98,6 +98,7 @@
             ownerCt: me,
             ownerLayout: me.getComponentLayout(),
             value: 0,
+            maxValue: 23,
             onSpinUp: function() {
                 var value = parseInt(this.getValue());
                 if (value === 23) {
@@ -134,6 +135,7 @@
             ownerCt: me,
             ownerLayout: me.getComponentLayout(),
             value: 0,
+            maxValue: 59,
             onSpinUp: function() {
                 var value = parseInt(this.getValue());
                 if (value === 59) {
@@ -214,7 +216,14 @@
         me.callParent();
     },
 
-    changeTimeValue: function (field, nValue, oValue) {
+    changeTimeValue: function (field, nValue) {
+        var value = parseInt(nValue);
+        if (value > field.maxValue) {
+            field.setValue(field.maxValue);
+        }
+        else if (value < 10 && (nValue.indexOf('0') !== 0 || nValue.length < 2)) {
+            field.setValue('0' + nValue);
+        }
     },
 
     setValue: function(value) {

http://lada.wald.intevation.org