fix(MultiCheck): Use df.sort_options to enable/disable sort (#24202)
When df.sort_options is null/undefined/truthy, then sort options. When df.sort_options is explicitely falsy, then do NOT sort options.
This commit is contained in:
parent
1666b0104f
commit
c9cccf0598
1 changed files with 11 additions and 9 deletions
|
|
@ -75,15 +75,17 @@ frappe.ui.form.ControlMultiCheck = class ControlMultiCheck extends frappe.ui.for
|
|||
make_checkboxes() {
|
||||
this.$load_state.hide();
|
||||
this.$checkbox_area.empty();
|
||||
this.options
|
||||
.sort((a, b) => cstr(a.label).localeCompare(cstr(b.label)))
|
||||
.forEach((option) => {
|
||||
let checkbox = this.get_checkbox_element(option).appendTo(this.$checkbox_area);
|
||||
if (option.danger) {
|
||||
checkbox.find(".label-area").addClass("text-danger");
|
||||
}
|
||||
option.$checkbox = checkbox;
|
||||
});
|
||||
if (this.df.sort_options != false) {
|
||||
// Sort if sort_options is undefined, null or truthy.
|
||||
this.options.sort((a, b) => cstr(a.label).localeCompare(cstr(b.label)));
|
||||
}
|
||||
this.options.forEach((option) => {
|
||||
let checkbox = this.get_checkbox_element(option).appendTo(this.$checkbox_area);
|
||||
if (option.danger) {
|
||||
checkbox.find(".label-area").addClass("text-danger");
|
||||
}
|
||||
option.$checkbox = checkbox;
|
||||
});
|
||||
if (this.df.select_all) {
|
||||
this.setup_select_all();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue