From e22542a2b143f797fb1600897d57d50b1e07923b Mon Sep 17 00:00:00 2001 From: prssanna Date: Fri, 26 Mar 2021 14:12:07 +0530 Subject: [PATCH] feat: don't render filters, sort, add doc button for dashbaord view --- frappe/public/js/frappe/list/base_list.js | 4 +++- frappe/public/js/frappe/list/list_view.js | 14 +++++++------- .../js/frappe/views/dashboard/dashboard_view.js | 6 ++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index 24e14ffc38..a2dc51d69b 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -285,6 +285,7 @@ frappe.views.BaseList = class BaseList { } setup_filter_area() { + if (this.hide_filters) return; this.filter_area = new FilterArea(this); if (this.filters && this.filters.length > 0) { @@ -293,6 +294,7 @@ frappe.views.BaseList = class BaseList { } setup_sort_selector() { + if (this.hide_sort_selector) return; this.sort_selector = new frappe.ui.SortSelector({ parent: this.$filter_section, doctype: this.doctype, @@ -410,7 +412,7 @@ frappe.views.BaseList = class BaseList { doctype: this.doctype, fields: this.get_fields(), filters: this.get_filters_for_args(), - order_by: this.sort_selector.get_sql_string(), + order_by: this.sort_selector && this.sort_selector.get_sql_string(), start: this.start, page_length: this.page_length, view: this.view, diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 48ae8b1d08..c55ec4b3ab 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -417,11 +417,11 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { get_no_result_message() { let help_link = this.get_documentation_link(); - let filters = this.filter_area.get(); - let no_result_message = filters.length + let filters = this.filter_area && this.filter_area.get(); + let no_result_message = filters && filters.length ? __("No {0} found", [__(this.doctype)]) : __("You haven't created a {0} yet", [__(this.doctype)]); - let new_button_label = filters.length + let new_button_label = filters && filters.length ? __("Create a new {0}", [__(this.doctype)]) : __("Create your first {0}", [__(this.doctype)]); let empty_state_image = @@ -461,7 +461,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { } before_refresh() { - if (frappe.route_options) { + if (frappe.route_options && this.filter_area) { this.filters = this.parse_filters_from_route_options(); frappe.route_options = null; @@ -527,9 +527,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { this.view_name ); this.save_view_user_settings({ - filters: this.filter_area.get(), - sort_by: this.sort_selector.sort_by, - sort_order: this.sort_selector.sort_order, + filters: this.filter_area && this.filter_area.get(), + sort_by: this.sort_selector && this.sort_selector.sort_by, + sort_order: this.sort_selector && this.sort_selector.sort_order, }); this.toggle_paging && this.$paging_area.toggle(false); } diff --git a/frappe/public/js/frappe/views/dashboard/dashboard_view.js b/frappe/public/js/frappe/views/dashboard/dashboard_view.js index 5137d840ec..252024463e 100644 --- a/frappe/public/js/frappe/views/dashboard/dashboard_view.js +++ b/frappe/public/js/frappe/views/dashboard/dashboard_view.js @@ -20,6 +20,8 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView { setup_page() { this.hide_sidebar = true; this.hide_page_form = true; + this.hide_filters = true; + this.hide_sort_selector = true; super.setup_page(); } @@ -74,6 +76,10 @@ frappe.views.DashboardView = class DashboardView extends frappe.views.ListView { this.toggle_customization_buttons(false); } + set_primary_action() { + // Don't render Add doc button for dashboard view + } + toggle_customization_buttons(show) { this.save_customizations_button.toggle(show); this.discard_customizations_button.toggle(show);