From 1c07ebbacfd1d88fc892175980a6188240034e6d Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 11 May 2022 14:39:22 -0400 Subject: [PATCH] Dashboard - Sort inactive dashlets by label, add search box. This makes dashlets easier to find if there is a large number. --- ang/crmDashboard/Dashboard.html | 5 +++-- ang/crmDashboard/crmDashboard.component.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ang/crmDashboard/Dashboard.html b/ang/crmDashboard/Dashboard.html index 8b500c1d4ac9..0a1610e100e7 100644 --- a/ang/crmDashboard/Dashboard.html +++ b/ang/crmDashboard/Dashboard.html @@ -1,17 +1,18 @@
- + {{ $ctrl.inactive.length === 1 ? ts('1 Available Dashlet') : ts('%1 Available Dashlets', {1: $ctrl.inactive.length}) }} +
{{ ts('Drag and drop dashlets onto the left or right columns below to add them to your dashboard. Changes are automatically saved.') }}
-
+
diff --git a/ang/crmDashboard/crmDashboard.component.js b/ang/crmDashboard/crmDashboard.component.js index a0600d427f0f..3e0db13d0d60 100644 --- a/ang/crmDashboard/crmDashboard.component.js +++ b/ang/crmDashboard/crmDashboard.component.js @@ -68,9 +68,27 @@ }); }, 2000); + // Sort inactive dashlets by label. This makes them easier to find if there is a large number. + function sortInactive() { + ctrl.inactive = _.sortBy(ctrl.inactive, 'label'); + } + + // Show/hide inactive dashlets + this.toggleInactive = function() { + // Ensure inactive dashlets are sorted before showing them + sortInactive(); + ctrl.showInactive = !ctrl.showInactive; + }; + + this.filterApplies = function(dashlet) { + return !ctrl.filterInactive || _.includes(dashlet.label.toLowerCase(), ctrl.filterInactive.toLowerCase()); + }; + this.removeDashlet = function(column, index) { ctrl.inactive.push(ctrl.columns[column][index]); ctrl.columns[column].splice(index, 1); + // Place the dashlet back in the correct abc order + sortInactive(); }; this.deleteDashlet = function(index) {