[FIX] web_editor: recursive checkbox check
In multi-level checkboxes, if there is only one checkbox per level, the expected behavior is that all checkbox will be checked if one of them is checked. This was not the case before this commit.
This commit is contained in:
@@ -143,7 +143,7 @@ class Web_Editor(http.Controller):
|
||||
ul = ul.getparent()
|
||||
|
||||
for child in ul.getchildren():
|
||||
if child.tag == 'li' and 'o_checked' not in child.get('class', ''):
|
||||
if child.tag == 'li' and 'checklist-id' in child.get('id', '') and 'o_checked' not in child.get('class', ''):
|
||||
allSelected = False
|
||||
|
||||
node = ul.getprevious()
|
||||
|
||||
@@ -432,6 +432,8 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
|
||||
if (ev.offsetX > 0) {
|
||||
return;
|
||||
}
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
var checked = $(ev.target).hasClass('o_checked');
|
||||
var checklistId = parseInt(($(ev.target).attr('id') || '0').replace(/^checklist-id-/, ''));
|
||||
|
||||
|
||||
@@ -2469,6 +2469,7 @@ function mouseDownChecklist (e) {
|
||||
if (!dom.isLi(e.target) || !$(e.target).parent('ul.o_checklist').length || e.offsetX > 0) {
|
||||
return;
|
||||
}
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var checked = $(e.target).hasClass('o_checked');
|
||||
$(e.target).toggleClass('o_checked', !checked);
|
||||
@@ -2478,12 +2479,14 @@ function mouseDownChecklist (e) {
|
||||
});
|
||||
if (checked) {
|
||||
$sublevel.removeClass('o_checked');
|
||||
$parents.prev('ul.o_checklist li').removeClass('o_checked');
|
||||
do {
|
||||
$parents = $parents.prev('ul.o_checklist li').removeClass('o_checked');
|
||||
} while ($parents.length);
|
||||
} else {
|
||||
$sublevel.addClass('o_checked');
|
||||
var $lis;
|
||||
do {
|
||||
$lis = $parents.not(':has(li:not(.o_checked))').prev('ul.o_checklist li:not(.o_checked)');
|
||||
$lis = $parents.not(':has(li[id^="checklist-id"]:not(.o_checked))').prev('ul.o_checklist li:not(.o_checked)');
|
||||
$lis.addClass('o_checked');
|
||||
} while ($lis.length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user