From 392752287335284279fa46fdb683ba17b5e5c9c2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari <30859809+shariquerik@users.noreply.github.com> Date: Mon, 1 Aug 2022 19:05:30 +0530 Subject: [PATCH] fix: Show Report & Dashboard View for File Doctype (#17688) --- frappe/public/js/frappe/list/list_factory.js | 11 ++++++++--- frappe/public/js/frappe/list/list_view_select.js | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/list/list_factory.js b/frappe/public/js/frappe/list/list_factory.js index ef48af4937..b0868b56b2 100644 --- a/frappe/public/js/frappe/list/list_factory.js +++ b/frappe/public/js/frappe/list/list_factory.js @@ -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' && diff --git a/frappe/public/js/frappe/list/list_view_select.js b/frappe/public/js/frappe/list/list_view_select.js index f531516f55..c3796e77a9 100644 --- a/frappe/public/js/frappe/list/list_view_select.js +++ b/frappe/public/js/frappe/list/list_view_select.js @@ -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(