Skip to content

Commit

Permalink
feat: don't render filters, sort, add doc button for dashbaord view
Browse files Browse the repository at this point in the history
  • Loading branch information
prssanna committed Mar 26, 2021
1 parent c0e949e commit e22542a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion frappe/public/js/frappe/list/base_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions frappe/public/js/frappe/list/list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions frappe/public/js/frappe/views/dashboard/dashboard_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e22542a

Please sign in to comment.