fix: Hide Menu if empty & render columns without state change

- 'Refresh' btn is always present in dropdown menu. Show menu if any other action is also present.
- Without `update_order` state is not changed, and thus columns are not rendered on `init()`
- If we are not updating order in the db, render columns with whatever information we have currently
This commit is contained in:
marination 2022-12-23 00:44:53 +05:30
parent 988b725b67
commit 5d0ad77d62
2 changed files with 14 additions and 2 deletions

View file

@ -328,9 +328,11 @@ frappe.provide("frappe.views");
}, show_empty_state);
if (frappe.model.can_write(store.state.doctype)) {
// Check for reference doctype access before initiating
// non-deliberate action
// Check for reference doctype access before trying to modify it's value
store.dispatch("update_order");
} else {
// Render columns without state change
make_columns();
}
}

View file

@ -45,6 +45,16 @@ frappe.views.KanbanView = class KanbanView extends frappe.views.ListView {
});
}
init() {
return super.init().then(() => {
let menu_length = this.page.menu.find(".dropdown-item").length;
if (menu_length === 1) {
// Only 'Refresh' (hidden) is present (always), dropdown is visibly empty
this.page.hide_menu();
}
});
}
setup_defaults() {
return super.setup_defaults().then(() => {
let get_board_name = () => {