Skip to content

Commit 7725eac

Browse files
author
Jeffrey Barrus
committed
feat(sort): sort priority indicator hiding
change sort priority indicator to only show when multiple columns are sorted
1 parent 54d6b58 commit 7725eac

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/js/core/directives/ui-grid-header-cell.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@
3131
headerCell: i18nService.getSafeText('headerCell'),
3232
sort: i18nService.getSafeText('sort')
3333
};
34+
$scope.isSortPriorityVisible = function() {
35+
//show sort priority if column is sorted and there is at least one other sorted column
36+
return $scope.col.sort.priority && $scope.grid.columns.some(function(element, index){
37+
return element.sort.priority && element !== $scope.col;
38+
});
39+
};
3440
$scope.getSortDirectionAriaLabel = function(){
3541
var col = $scope.col;
3642
//Trying to recreate this sort of thing but it was getting messy having it in the template.
3743
//Sort direction {{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending':'none')}}. {{col.sort.priority ? {{columnPriorityText}} {{col.sort.priority}} : ''}
3844
var sortDirectionText = col.sort.direction === uiGridConstants.ASC ? $scope.i18n.sort.ascending : ( col.sort.direction === uiGridConstants.DESC ? $scope.i18n.sort.descending : $scope.i18n.sort.none);
3945
var label = sortDirectionText;
40-
//Append the priority if it exists
41-
if (col.sort.priority) {
46+
47+
if ($scope.isSortPriorityVisible()) {
4248
label = label + '. ' + $scope.i18n.headerCell.priority + ' ' + col.sort.priority;
4349
}
4450
return label;

src/templates/ui-grid/uiGridHeaderCell.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
aria-label="{{getSortDirectionAriaLabel()}}">
2222
<i
2323
ng-class="{ 'ui-grid-icon-up-dir': col.sort.direction == asc, 'ui-grid-icon-down-dir': col.sort.direction == desc, 'ui-grid-icon-blank': !col.sort.direction }"
24-
title="{{col.sort.priority ? i18n.headerCell.priority + ' ' + col.sort.priority : null}}"
24+
title="{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + col.sort.priority : null}}"
2525
aria-hidden="true">
2626
</i>
2727
<sub
28+
ui-grid-visible="isSortPriorityVisible()"
2829
class="ui-grid-sort-priority-number">
2930
{{col.sort.priority}}
3031
</sub>

0 commit comments

Comments
 (0)