Skip to content

Commit

Permalink
perf: Lazily compute common workflow transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Jul 20, 2023
1 parent 948b24e commit c90374c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frappe/public/js/frappe/list/list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
if (toggle) {
this.page.show_actions_menu();
this.page.clear_primary_action();
this.toggle_workflow_actions();
} else {
this.page.hide_actions_menu();
this.set_primary_action();
Expand Down Expand Up @@ -1313,6 +1312,11 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {

this.update_checkbox($target);
});

let me = this;
this.page.actions_btn_group.on("show.bs.dropdown", () => {
me.toggle_workflow_actions();
});
}

setup_like() {
Expand Down Expand Up @@ -1697,14 +1701,20 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {

toggle_workflow_actions() {
if (!frappe.model.has_workflow(this.doctype)) return;

Object.keys(this.workflow_action_items).forEach((key) => {
this.workflow_action_items[key].addClass("disabled");
});
const checked_items = this.get_checked_items();

frappe
.xcall("frappe.model.workflow.get_common_transition_actions", {
docs: checked_items,
doctype: this.doctype,
})
.then((actions) => {
Object.keys(this.workflow_action_items).forEach((key) => {
this.workflow_action_items[key].removeClass("disabled");
this.workflow_action_items[key].toggle(actions.includes(key));
});
});
Expand Down

0 comments on commit c90374c

Please sign in to comment.