Skip to content

Commit

Permalink
fix: Show Report & Dashboard View for File Doctype (#17688)
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Aug 1, 2022
1 parent 2e85a49 commit 3927522
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions frappe/public/js/frappe/list/list_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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' &&
Expand Down
5 changes: 4 additions & 1 deletion frappe/public/js/frappe/list/list_view_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3927522

Please sign in to comment.