changeset fc4903828b1e in sao:5.2
details: https://hg.tryton.org/sao?cmd=changeset;node=fc4903828b1e
description:
        Keep showing invalid input number and set NaN on the model

        When a dialog (form) is validated and show the error message from the 
browser,
        the input number must be visible.
        Also we should not store on the model invalid values to get error on 
client
        side instead of the server side.

        issue8487
        review255661002
        (grafted from fe4e608239f24188a2f90d804e835b59385d13c6)
diffstat:

 src/view/form.js |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r d62f3fc5f60e -r fc4903828b1e src/view/form.js
--- a/src/view/form.js  Mon Jul 08 21:26:20 2019 +0200
+++ b/src/view/form.js  Wed Jul 17 22:48:59 2019 +0200
@@ -1535,8 +1535,10 @@
         input.attr('lang', Sao.i18n.getlang());
 
         input.hide().on('focusout', function() {
-            input.hide();
-            input_text.show();
+            if (input[0].checkValidity()) {
+                input.hide();
+                input_text.show();
+            }
         });
         input_text.on('focusin', function() {
             if (!input.prop('readonly')) {
@@ -1560,7 +1562,14 @@
         },
         set_value: function() {
             this.field.set_client(
-                this.record, this.input.val(), undefined, this.factor);
+                this.record, this.get_value(), undefined, this.factor);
+        },
+        get_value: function() {
+            if (this.input[0].checkValidity()) {
+                return this.input.val();
+            } else {
+                return NaN;
+            }
         },
         get_client_value: function() {
             var value = '';

Reply via email to