details: https://code.tryton.org/tryton/commit/b96790c6ef3d
branch: default
user: Cédric Krier <[email protected]>
date: Thu Feb 19 17:06:41 2026 +0100
description:
Select option on double click in selection dialog
The form submit event is triggered when the radio div is double clicked.
The radio elements are put in a form-group to restore margin since
81bc564e03e0.
And the option is required to submit the form.
Closes #14616
diffstat:
sao/src/common.js | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diffs (56 lines):
diff -r b2bcb8b91404 -r b96790c6ef3d sao/src/common.js
--- a/sao/src/common.js Fri Jan 23 19:09:31 2026 +0100
+++ b/sao/src/common.js Thu Feb 19 17:06:41 2026 +0100
@@ -189,7 +189,15 @@
dialog.modal.uniqueId();
keys.forEach(function(k, i) {
+ let checked;
+ if (!default_) {
+ checked = !i;
+ } else {
+ checked = values[keys[i]] == default_;
+ }
jQuery('<div/>', {
+ 'class': 'form-group',
+ }).append(jQuery('<div/>', {
'class': 'radio'
}).append(jQuery('<label/>')
.text(' ' + k)
@@ -197,13 +205,11 @@
'type': 'radio',
'name': 'selection-' + dialog.modal.attr('id'),
'value': i,
- 'checked': values[keys[i]] == default_,
- })))
+ 'checked': checked,
+ 'required': true,
+ }))).dblclick(() => dialog.content.submit()))
.appendTo(dialog.body);
});
- if (!default_) {
- dialog.body.find('input').first().prop('checked', true);
- }
jQuery('<button/>', {
'class': 'btn btn-link',
@@ -215,13 +221,16 @@
}).appendTo(dialog.footer);
jQuery('<button/>', {
'class': 'btn btn-primary',
- 'type': 'button',
+ 'type': 'submit',
'title': Sao.i18n.gettext("OK"),
- }).text(Sao.i18n.gettext('OK')).click(function() {
+ }).text(Sao.i18n.gettext('OK')
+ ).appendTo(dialog.footer);
+ dialog.content.submit(evt => {
+ evt.preventDefault();
var i = dialog.body.find('input:checked').attr('value');
dialog.modal.modal('hide');
prm.resolve(values[keys[i]]);
- }).appendTo(dialog.footer);
+ });
dialog.modal.on('hidden.bs.modal', function(e) {
jQuery(this).remove();
});