changeset dc505d15a367 in sao:5.4
details: https://hg.tryton.org/sao?cmd=changeset;node=dc505d15a367
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
        (grafted from 6706f4c73bccf23578fd41371e6e86e004ad3d78)
diffstat:

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

diffs (42 lines):

diff -r 55823a0c8315 -r dc505d15a367 src/common.js
--- a/src/common.js     Sat Nov 30 22:44:57 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