Skip to content

Commit

Permalink
Add truncation details to group heading
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Aug 5, 2020
1 parent d9fb138 commit 0975f02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions ui/app/components/global-search/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export default class GlobalSearchControl extends Component {

return [
{
groupName: `Jobs (${this.jobSearch.listSearched.length})`,
groupName: resultsGroupLabel('Jobs', jobResults, this.jobSearch.listSearched),
options: jobResults,
},
{
groupName: `Clients (${this.nodeSearch.listSearched.length})`,
groupName: resultsGroupLabel('Clients', nodeResults, this.nodeSearch.listSearched),
options: nodeResults,
},
];
Expand Down Expand Up @@ -180,3 +180,15 @@ class NodeSearch extends EmberObject.extend(Searchable) {
fuzzySearchEnabled = true;
includeFuzzySearchMatches = true;
}

function resultsGroupLabel(type, renderedResults, allResults) {
let countString;

if (renderedResults.length < allResults.length) {
countString = `showing ${renderedResults.length} of ${allResults.length}`;
} else {
countString = renderedResults.length;
}

return `${type} (${countString})`;
}
2 changes: 1 addition & 1 deletion ui/tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module('Acceptance | search', function(hooks) {

PageLayout.navbar.search.as(search => {
search.groups[0].as(jobs => {
assert.equal(jobs.name, 'Jobs (15)');
assert.equal(jobs.name, 'Jobs (showing 10 of 15)');
assert.equal(jobs.options.length, 10);
});
});
Expand Down

0 comments on commit 0975f02

Please sign in to comment.