Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard - Sort available dashlets alphabetically, add search box #23438

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ang/crmDashboard/Dashboard.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<div id="civicrm-dashboard">
<fieldset class="crm-inactive-dashlet-fieldset">
<legend>
<a href class="crm-hover-button" ng-click="$ctrl.showInactive = !$ctrl.showInactive">
<a href class="crm-hover-button" ng-click="$ctrl.toggleInactive()">
<i class="crm-i fa-{{ $ctrl.showInactive ? 'minus' : 'plus' }}" aria-hidden="true"></i>
{{ $ctrl.inactive.length === 1 ? ts('1 Available Dashlet') : ts('%1 Available Dashlets', {1: $ctrl.inactive.length}) }}
</a>
<input ng-if="$ctrl.showInactive" class="crm-form-text" ng-model="$ctrl.filterInactive" type="search" placeholder="{{:: ts('Filter by title...') }}">
</legend>
<div ng-if="$ctrl.showInactive" ng-model="$ctrl.inactive" ui-sortable="$ctrl.sortableOptions" class="crm-dashboard-droppable">
<div class="help">
{{ ts('Drag and drop dashlets onto the left or right columns below to add them to your dashboard. Changes are automatically saved.') }}
<a crm-ui-help="hs({id: 'dash_configure', title: ts('Dashboard Configuration')})"></a>
</div>
<div ng-repeat="dashlet in $ctrl.inactive" class="crm-inactive-dashlet">
<div ng-repeat="dashlet in $ctrl.inactive" class="crm-inactive-dashlet" ng-show="$ctrl.filterApplies(dashlet)">
<crm-inactive-dashlet dashlet="dashlet" delete="$ctrl.deleteDashlet($index)"></crm-inactive-dashlet>
</div>
</div>
Expand Down
18 changes: 18 additions & 0 deletions ang/crmDashboard/crmDashboard.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down