Skip to content

feat(sort): change sort priority indicator to only show when multiple columns are sorted #4876

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

Merged
merged 2 commits into from
Jan 14, 2016
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
10 changes: 8 additions & 2 deletions src/js/core/directives/ui-grid-header-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@
headerCell: i18nService.getSafeText('headerCell'),
sort: i18nService.getSafeText('sort')
};
$scope.isSortPriorityVisible = function() {
//show sort priority if column is sorted and there is at least one other sorted column
return $scope.col.sort.priority && $scope.grid.columns.some(function(element, index){
return element.sort.priority && element !== $scope.col;
});
};
$scope.getSortDirectionAriaLabel = function(){
var col = $scope.col;
//Trying to recreate this sort of thing but it was getting messy having it in the template.
//Sort direction {{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending':'none')}}. {{col.sort.priority ? {{columnPriorityText}} {{col.sort.priority}} : ''}
var sortDirectionText = col.sort.direction === uiGridConstants.ASC ? $scope.i18n.sort.ascending : ( col.sort.direction === uiGridConstants.DESC ? $scope.i18n.sort.descending : $scope.i18n.sort.none);
var label = sortDirectionText;
//Append the priority if it exists
if (col.sort.priority) {

if ($scope.isSortPriorityVisible()) {
label = label + '. ' + $scope.i18n.headerCell.priority + ' ' + col.sort.priority;
}
return label;
Expand Down
3 changes: 2 additions & 1 deletion src/templates/ui-grid/uiGridHeaderCell.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
aria-label="{{getSortDirectionAriaLabel()}}">
<i
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 }"
title="{{col.sort.priority ? i18n.headerCell.priority + ' ' + col.sort.priority : null}}"
title="{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + col.sort.priority : null}}"
aria-hidden="true">
</i>
<sub
ui-grid-visible="isSortPriorityVisible()"
class="ui-grid-sort-priority-number">
{{col.sort.priority}}
</sub>
Expand Down