From c1e20c84b4c8a201d7d10224eef48e320787916a Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:47:57 +0100 Subject: [PATCH 1/7] fix: clear all filters when in list view --- frappe/public/js/frappe/ui/filters/filter_list.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/ui/filters/filter_list.js b/frappe/public/js/frappe/ui/filters/filter_list.js index 3119ee4b68..69d089ef3a 100644 --- a/frappe/public/js/frappe/ui/filters/filter_list.js +++ b/frappe/public/js/frappe/ui/filters/filter_list.js @@ -128,7 +128,14 @@ frappe.ui.FilterGroup = class { this.wrapper.find(".clear-filters").on("click", () => { this.toggle_empty_filters(true); - this.clear_filters(); + if (typeof this.base_list !== "undefined") { + // It's a list view. Clear all the filters, also the ones in the + // FilterArea outside this FilterGroup + this.base_list.filter_area.clear(); + } else { + // Not a list view, just clear the filters in this FilterGroup + this.clear_filters(); + } this.on_change(); }); From 8500f61b8a3b387f7f01e94dc4c027c01b12271e Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:51:46 +0100 Subject: [PATCH 2/7] refactor: method hide_popover --- frappe/public/js/frappe/ui/filters/filter_list.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/ui/filters/filter_list.js b/frappe/public/js/frappe/ui/filters/filter_list.js index 69d089ef3a..25344b8e57 100644 --- a/frappe/public/js/frappe/ui/filters/filter_list.js +++ b/frappe/public/js/frappe/ui/filters/filter_list.js @@ -17,6 +17,10 @@ frappe.ui.FilterGroup = class { this.set_popover_events(); } + hide_popover() { + this.filter_button.popover("hide"); + } + init_filter_popover() { this.filter_button.popover({ content: this.get_filter_area_template(), @@ -54,7 +58,7 @@ frappe.ui.FilterGroup = class { !$(e.target).is(this.filter_button) && !in_datepicker ) { - this.wrapper && this.filter_button.popover("hide"); + this.wrapper && this.hide_popover(); } } }); @@ -85,7 +89,7 @@ frappe.ui.FilterGroup = class { // REDESIGN-TODO: (Temporary) Review and find best solution for this frappe.router.on("change", () => { if (this.wrapper && this.wrapper.is(":visible")) { - this.filter_button.popover("hide"); + this.hide_popover(); } }); } @@ -139,9 +143,7 @@ frappe.ui.FilterGroup = class { this.on_change(); }); - this.wrapper.find(".apply-filters").on("click", () => { - this.filter_button.popover("hide"); - }); + this.wrapper.find(".apply-filters").on("click", () => this.hide_popover()); } add_filters(filters) { From eb398097b7defd1fca215d974ddf54344c0cbced Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:54:15 +0100 Subject: [PATCH 3/7] fix: hide popover after clearing filters --- frappe/public/js/frappe/ui/filters/filter_list.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frappe/public/js/frappe/ui/filters/filter_list.js b/frappe/public/js/frappe/ui/filters/filter_list.js index 25344b8e57..1ae26a34fc 100644 --- a/frappe/public/js/frappe/ui/filters/filter_list.js +++ b/frappe/public/js/frappe/ui/filters/filter_list.js @@ -141,6 +141,7 @@ frappe.ui.FilterGroup = class { this.clear_filters(); } this.on_change(); + this.hide_popover(); }); this.wrapper.find(".apply-filters").on("click", () => this.hide_popover()); From 7037b408a3624f12343b26d384ba55a38f405d49 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 11 Apr 2023 17:21:06 +0530 Subject: [PATCH 4/7] fix: separate clear all filter button grouped with filter button --- frappe/public/icons/timeless/icons.svg | 10 ++++++-- frappe/public/js/frappe/list/base_list.js | 23 +++++++++++------ .../js/frappe/ui/filters/filter_list.js | 25 +++++++++++++------ frappe/public/scss/desk/filters.scss | 4 +-- frappe/public/scss/desk/list.scss | 5 ++-- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/frappe/public/icons/timeless/icons.svg b/frappe/public/icons/timeless/icons.svg index cfaf3ba1d7..b1b5448fee 100644 --- a/frappe/public/icons/timeless/icons.svg +++ b/frappe/public/icons/timeless/icons.svg @@ -237,8 +237,14 @@ - - + + + + + + + + diff --git a/frappe/public/js/frappe/list/base_list.js b/frappe/public/js/frappe/list/base_list.js index 600db57dd1..f581165f0b 100644 --- a/frappe/public/js/frappe/list/base_list.js +++ b/frappe/public/js/frappe/list/base_list.js @@ -830,22 +830,31 @@ class FilterArea { make_filter_list() { $(`
- + + + +
`).appendTo(this.$filter_list_wrapper); this.filter_button = this.$filter_list_wrapper.find(".filter-button"); + this.filter_x_button = this.$filter_list_wrapper.find(".filter-x-button"); this.filter_list = new frappe.ui.FilterGroup({ base_list: this.list_view, parent: this.$filter_list_wrapper, doctype: this.list_view.doctype, filter_button: this.filter_button, + filter_x_button: this.filter_x_button, default_filters: [], on_change: () => this.refresh_list_view(), }); diff --git a/frappe/public/js/frappe/ui/filters/filter_list.js b/frappe/public/js/frappe/ui/filters/filter_list.js index 1ae26a34fc..5a8d14e09f 100644 --- a/frappe/public/js/frappe/ui/filters/filter_list.js +++ b/frappe/public/js/frappe/ui/filters/filter_list.js @@ -14,9 +14,25 @@ frappe.ui.FilterGroup = class { make_popover() { this.init_filter_popover(); + this.set_clear_all_filters_event(); this.set_popover_events(); } + set_clear_all_filters_event() { + this.filter_x_button.on("click", () => { + this.toggle_empty_filters(true); + if (typeof this.base_list !== "undefined") { + // It's a list view. Clear all the filters, also the ones in the + // FilterArea outside this FilterGroup + this.base_list.filter_area.clear(); + } else { + // Not a list view, just clear the filters in this FilterGroup + this.clear_filters(); + } + this.update_filter_button(); + }); + } + hide_popover() { this.filter_button.popover("hide"); } @@ -132,14 +148,7 @@ frappe.ui.FilterGroup = class { this.wrapper.find(".clear-filters").on("click", () => { this.toggle_empty_filters(true); - if (typeof this.base_list !== "undefined") { - // It's a list view. Clear all the filters, also the ones in the - // FilterArea outside this FilterGroup - this.base_list.filter_area.clear(); - } else { - // Not a list view, just clear the filters in this FilterGroup - this.clear_filters(); - } + this.clear_filters(); this.on_change(); this.hide_popover(); }); diff --git a/frappe/public/scss/desk/filters.scss b/frappe/public/scss/desk/filters.scss index ffaea7a9bd..3f197e8278 100644 --- a/frappe/public/scss/desk/filters.scss +++ b/frappe/public/scss/desk/filters.scss @@ -1,7 +1,5 @@ .filter-icon.active { - use { - stroke: var(--text-on-blue); - } + --icon-stroke: var(--text-on-blue); } .filter-popover { diff --git a/frappe/public/scss/desk/list.scss b/frappe/public/scss/desk/list.scss index 31d1661abb..a9a80a3f06 100644 --- a/frappe/public/scss/desk/list.scss +++ b/frappe/public/scss/desk/list.scss @@ -395,9 +395,8 @@ input.list-check-all { padding: 0 var(--padding-xs); } - .filter-button { - margin: 5px; - // padding: 4px 8px; + .filter-selector .btn-group { + margin: var(--margin-xs); } .filter-button.btn-primary-light { From eeedfd0f2c2957f76402aed7b1b52f5ffcd852a1 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 11 Apr 2023 18:09:26 +0530 Subject: [PATCH 5/7] fix: filter button border when have active filters --- frappe/public/scss/desk/list.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frappe/public/scss/desk/list.scss b/frappe/public/scss/desk/list.scss index a9a80a3f06..186537f341 100644 --- a/frappe/public/scss/desk/list.scss +++ b/frappe/public/scss/desk/list.scss @@ -401,6 +401,8 @@ input.list-check-all { .filter-button.btn-primary-light { color: var(--text-on-blue); + outline: 1px solid var(--bg-dark-blue); + z-index: 1; } .sort-selector { From 844f25e6461e62c25512caf8077a03cbb708d2a1 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 12 Apr 2023 18:09:07 +0530 Subject: [PATCH 6/7] chore: minor change in the filter icons --- frappe/public/icons/timeless/icons.svg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frappe/public/icons/timeless/icons.svg b/frappe/public/icons/timeless/icons.svg index b1b5448fee..aeef96ccfe 100644 --- a/frappe/public/icons/timeless/icons.svg +++ b/frappe/public/icons/timeless/icons.svg @@ -238,13 +238,13 @@
- + - - - + + + From c12406fa3e0507695ce971f3edd64eb0e70e3317 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 17 Apr 2023 14:38:27 +0530 Subject: [PATCH 7/7] test: fixed failing UI test --- cypress/integration/folder_navigation.js | 3 +-- cypress/integration/sidebar.js | 2 +- cypress/support/commands.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cypress/integration/folder_navigation.js b/cypress/integration/folder_navigation.js index c5b3a44f0d..1f2f4dfe67 100644 --- a/cypress/integration/folder_navigation.js +++ b/cypress/integration/folder_navigation.js @@ -7,8 +7,7 @@ context("Folder Navigation", () => { it("Adding Folders", () => { //Adding filter to go into the home folder - cy.get(".filter-selector > .btn").findByText("1 filter").click(); - cy.findByRole("button", { name: "Clear Filters" }).click(); + cy.get(".filter-x-button").click(); cy.get(".filter-action-buttons > .text-muted").findByText("+ Add a Filter").click(); cy.get(".fieldname-select-area > .awesomplete > .form-control:last").type("Fol{enter}"); cy.get( diff --git a/cypress/integration/sidebar.js b/cypress/integration/sidebar.js index 0b2a21aa4f..0f97cdc7fe 100644 --- a/cypress/integration/sidebar.js +++ b/cypress/integration/sidebar.js @@ -53,7 +53,7 @@ context("Sidebar", () => { ); //To check if there is no filter added to the listview - cy.get(".filter-selector > .btn").should("contain", "Filter"); + cy.get(".filter-button").should("contain", "Filter"); //To add a filter to display data into the listview cy.get(".group-by-field.show > .dropdown-menu > .group-by-item > .dropdown-item").click(); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c067974d9f..4b44a24598 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -479,7 +479,7 @@ Cypress.Commands.add("click_listview_row_item_with_text", (text) => { }); Cypress.Commands.add("click_filter_button", () => { - cy.get(".filter-selector > .btn").click(); + cy.get(".filter-button").click(); }); Cypress.Commands.add("click_listview_primary_button", (btn_name) => {