changeset 8058db617181 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=8058db617181
description:
        Keep 0 as value for numeric Dict and keep step of 1 for integer

        issue10123
        review357681002
diffstat:

 src/view/form.js |  57 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 27 deletions(-)

diffs (84 lines):

diff -r 8dcb3f10cbd2 -r 8058db617181 src/view/form.js
--- a/src/view/form.js  Sun Apr 11 18:29:21 2021 +0200
+++ b/src/view/form.js  Sun Apr 11 18:32:18 2021 +0200
@@ -4864,12 +4864,37 @@
             }
         });
 
-    Sao.View.Form.Dict.Float = Sao.class_(Sao.View.Form.Dict.Entry, {
-        class_: 'dict-float',
+    Sao.View.Form.Dict.Integer = Sao.class_(Sao.View.Form.Dict.Entry, {
+        class_: 'dict-integer',
         create_widget: function() {
-            Sao.View.Form.Dict.Float._super.create_widget.call(this);
+            Sao.View.Form.Dict.Integer._super.create_widget.call(this);
             this.input_text = this.labelled = integer_input(this.input);
         },
+        get_value: function() {
+            var value = parseInt(this.input.val(), 10);
+            if (isNaN(value)) {
+                return null;
+            }
+            return value;
+        },
+        set_value: function(value, options) {
+            if (value !== null) {
+                this.input.val(value);
+                this.input_text.val(value.toLocaleString(
+                    Sao.i18n.BC47(Sao.i18n.getlang()), options));
+            } else {
+                this.input.val('');
+                this.input_text.val('');
+            }
+        },
+        set_readonly: function(readonly) {
+            Sao.View.Form.Dict.Integer._super.set_readonly.call(this, 
readonly);
+            this.input_text.prop('readonly', readonly);
+        },
+    });
+
+    Sao.View.Form.Dict.Float = Sao.class_(Sao.View.Form.Dict.Integer, {
+        class_: 'dict-float',
         get digits() {
             var record = this.parent_widget.record;
             if (record) {
@@ -4899,18 +4924,8 @@
                 options.maximumFractionDigits = digits[1];
             }
             this.input.attr('step', step);
-            Sao.View.Form.Dict.Float._super.set_value.call(this, value);
-            if (value !== null) {
-                this.input_text.val(value.toLocaleString(
-                    Sao.i18n.BC47(Sao.i18n.getlang()), options));
-            } else {
-                this.input_text.val('');
-            }
-        },
-        set_readonly: function(readonly) {
-            Sao.View.Form.Dict.Float._super.set_readonly.call(this, readonly);
-            this.input_text.prop('readonly', readonly);
-        }
+            Sao.View.Form.Dict.Float._super.set_value.call(this, value, 
options);
+        },
     });
 
     Sao.View.Form.Dict.Numeric = Sao.class_(Sao.View.Form.Dict.Float, {
@@ -4924,18 +4939,6 @@
         }
     });
 
-    Sao.View.Form.Dict.Integer = Sao.class_(Sao.View.Form.Dict.Float, {
-        class_: 'dict-integer',
-        get_value: function() {
-            var value = parseInt(this.input.val(), 10);
-            if (isNaN(value)) {
-                return null;
-            }
-            return value;
-        },
-    });
-
-
     Sao.View.Form.Dict.Date = Sao.class_(Sao.View.Form.Dict.Entry, {
         class_: 'dict-date',
         format: '%x',

Reply via email to