Subject: changeset in sao:default Only parse the date content on Enter
From: Cédric Krier <[email protected]>

changeset 53405abc68af in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=53405abc68af
description:
        Only parse the date content on Enter

        It should not set the date value to today but only parse the existing 
input as
        a date.

        issue8043
        review50741002
diffstat:

 src/screen.js    |   9 +++++----
 src/view/form.js |  12 +++++++-----
 2 files changed, 12 insertions(+), 9 deletions(-)

diffs (44 lines):

diff -r dc9b2509ddad -r 53405abc68af src/screen.js
--- a/src/screen.js     Sun Feb 10 22:54:30 2019 +0100
+++ b/src/screen.js     Wed Feb 13 10:25:09 2019 +0100
@@ -581,10 +581,11 @@
                 entry.data('DateTimePicker').format(format);
                 var mousetrap = new Mousetrap(el[0]);
 
-                mousetrap.bind(['enter', '='], function(e, combo) {
-                    if (e.which != Sao.common.RETURN_KEYCODE) {
-                        e.preventDefault();
-                    }
+                mousetrap.bind('enter', function(e, combo) {
+                    entry.data('DateTimePicker').date();
+                });
+                mousetrap.bind('=', function(e, combo) {
+                    e.preventDefault();
                     entry.data('DateTimePicker').date(moment());
                 });
 
diff -r dc9b2509ddad -r 53405abc68af src/view/form.js
--- a/src/view/form.js  Sun Feb 10 22:54:30 2019 +0100
+++ b/src/view/form.js  Wed Feb 13 10:25:09 2019 +0100
@@ -1524,14 +1524,16 @@
             }.bind(this));
             var mousetrap = new Mousetrap(this.el[0]);
 
-            mousetrap.bind(['enter', '='], function(e, combo) {
-                if (this.date.find('input').prop('readonly')) {
-                    return;
+            mousetrap.bind('enter', function(e, combo) {
+                if (!this.date.find('input').prop('readonly')) {
+                    this.date.data('DateTimePicker').date();
                 }
-                if (e.which != Sao.common.RETURN_KEYCODE) {
+            }.bind(this));
+            mousetrap.bind('=', function(e, combo) {
+                if (!this.date.find('input').prop('readonly')) {
                     e.preventDefault();
+                    this.date.data('DateTimePicker').date(moment());
                 }
-                this.date.data('DateTimePicker').date(moment());
             }.bind(this));
 
             Sao.common.DATE_OPERATORS.forEach(function(operator) {

Reply via email to