diff --git a/src/js/core/directives/ui-grid-header-cell.js b/src/js/core/directives/ui-grid-header-cell.js index 4d5c289926..7e28d56d86 100644 --- a/src/js/core/directives/ui-grid-header-cell.js +++ b/src/js/core/directives/ui-grid-header-cell.js @@ -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; diff --git a/src/templates/ui-grid/uiGridHeaderCell.html b/src/templates/ui-grid/uiGridHeaderCell.html index 58a4c4d841..1c7e9a3005 100644 --- a/src/templates/ui-grid/uiGridHeaderCell.html +++ b/src/templates/ui-grid/uiGridHeaderCell.html @@ -21,10 +21,11 @@ aria-label="{{getSortDirectionAriaLabel()}}"> {{col.sort.priority}}