From 7ce766d9d4f555f56bace547c37c3b9254e8b79c Mon Sep 17 00:00:00 2001 From: Marcus Efraimsson Date: Mon, 27 Nov 2017 11:32:03 +0100 Subject: [PATCH] dashlist: Support for clear all filters --- .../features/dashboard/dashboard_list_ctrl.ts | 11 ++++- .../dashboard/partials/dashboardList.html | 12 ++++++ .../specs/dashboard_list_ctrl.jest.ts | 42 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/dashboard_list_ctrl.ts b/public/app/features/dashboard/dashboard_list_ctrl.ts index ab62e3dfff6..08bba6450f9 100644 --- a/public/app/features/dashboard/dashboard_list_ctrl.ts +++ b/public/app/features/dashboard/dashboard_list_ctrl.ts @@ -10,6 +10,7 @@ export class DashboardListCtrl { navModel: any; canDelete = false; canMove = false; + hasFilters = false; selectAllChecked = false; starredFilterOptions = [{text: 'Filter by Starred', disabled: true}, {text: 'Yes'}, {text: 'No'}]; selectedStarredFilter: any; @@ -17,7 +18,7 @@ export class DashboardListCtrl { /** @ngInject */ constructor(private backendSrv, navModelSrv, private $q, private searchSrv: SearchSrv) { this.navModel = navModelSrv.getNav('dashboards', 'dashboards'); - this.query = {query: '', mode: 'tree', tag: []}; + this.query = {query: '', mode: 'tree', tag: [], starred: false}; this.selectedStarredFilter = this.starredFilterOptions[0]; this.getDashboards().then(() => { @@ -35,6 +36,7 @@ export class DashboardListCtrl { this.canMove = false; this.canDelete = false; this.selectAllChecked = false; + this.hasFilters = this.query.query.length > 0 || this.query.tag.length > 0 || this.query.starred; if (!result) { this.sections = []; @@ -194,4 +196,11 @@ export class DashboardListCtrl { this.selectionChanged(); } + + clearFilters() { + this.query.query = ''; + this.query.tag = []; + this.query.starred = false; + this.getDashboards(); + } } diff --git a/public/app/features/dashboard/partials/dashboardList.html b/public/app/features/dashboard/partials/dashboardList.html index 4c574c5a5ba..c9822efe561 100644 --- a/public/app/features/dashboard/partials/dashboardList.html +++ b/public/app/features/dashboard/partials/dashboardList.html @@ -32,6 +32,18 @@ +
+
+ +
+
+