changeset 6706f4c73bcc in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=6706f4c73bcc
description:
        Properly test always checkbox in user warning

        We stop using callback on checkbox to store the value but use directly 
the
        value from the widget.

        issue8847
        review272541002
diffstat:

 src/common.js |  22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diffs (42 lines):

diff -r c318e2c8021b -r 6706f4c73bcc src/common.js
--- a/src/common.js     Thu Dec 05 21:34:49 2019 +0100
+++ b/src/common.js     Thu Dec 05 21:43:59 2019 +0100
@@ -2953,20 +2953,18 @@
 
     Sao.common.UserWarningDialog = Sao.class_(Sao.common.WarningDialog, {
         class_: 'user-warning-dialog',
-        always: false,
-        _set_always: function() {
-            this.always = jQuery(this).prop('checked');
-        },
         build_dialog: function(message, title, prm) {
             var dialog = Sao.common.UserWarningDialog._super.build_dialog.call(
                 this, message, title, prm);
-            dialog.body.append(jQuery('<div/>')
-                .append(jQuery('<input/>', {
-                    'type': 'checkbox'
-                }).change(this._set_always.bind(this)))
-                .append(jQuery('<span/>')
-                    .text(Sao.i18n.gettext('Always ignore this warning.')))
-                );
+            var always = jQuery('<input/>', {
+                'type': 'checkbox'
+            });
+            dialog.body.append(jQuery('<div/>', {
+                'class': 'checkbox',
+            }).append(jQuery('<label/>')
+                .append(always)
+                .append(Sao.i18n.gettext('Always ignore this warning.')))
+            );
             dialog.body.append(jQuery('<p/>')
                     .text(Sao.i18n.gettext('Do you want to proceed?')));
             dialog.footer.empty();
@@ -2982,7 +2980,7 @@
                 'type': 'button'
             }).append(Sao.i18n.gettext('Yes')).click(function() {
                 this.close(dialog);
-                if (this.always) {
+                if (always.prop('checked')) {
                     prm.resolve('always');
                 }
                 prm.resolve('ok');

Reply via email to