fix: Show Report & Dashboard View for File Doctype (#17688)

This commit is contained in:
Shariq Ansari 2022-08-01 19:05:30 +05:30 committed by GitHub
parent 2e85a49fd2
commit 3927522873
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -5,13 +5,18 @@ frappe.provide('frappe.views.list_view');
window.cur_list = null;
frappe.views.ListFactory = class ListFactory extends frappe.views.Factory {
make (route) {
make(route) {
const me = this;
const doctype = route[1];
// List / Gantt / Kanban / etc
let view_name = frappe.utils.to_title_case(route[2] || 'List');
// File is a special view
const view_name = doctype !== 'File' ? frappe.utils.to_title_case(route[2] || 'List') : 'File';
if (doctype == "File" && !["Report", "Dashboard"].includes(view_name)) {
view_name = "File";
}
let view_class = frappe.views[view_name + 'View'];
if (!view_class) view_class = frappe.views.ListView;
@ -48,7 +53,7 @@ frappe.views.ListFactory = class ListFactory extends frappe.views.Factory {
const last_route = frappe.route_history.slice(-2)[0];
if (
this.route[0] === 'List' &&
this.route.length === 2 &&
this.route.length === 2 &&
frappe.views.list_view[doctype] &&
last_route &&
last_route[0] === 'List' &&

View file

@ -8,6 +8,9 @@ frappe.views.ListViewSelect = class ListViewSelect {
}
add_view_to_menu(view, action) {
if (this.doctype == "File" && view == "List") {
view = "File";
}
let $el = this.page.add_custom_menu_item(
this.parent,
__(view),
@ -116,7 +119,7 @@ frappe.views.ListViewSelect = class ListViewSelect {
action: () => this.set_route("tree")
},
Kanban: {
condition: true,
condition: this.doctype != "File",
action: () => this.setup_kanban_boards(),
current_view_handler: () => {
frappe.views.KanbanView.get_kanbans(this.doctype).then(