Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Sorting #312

Merged
merged 10 commits into from
Mar 27, 2015
Merged

Sorting #312

merged 10 commits into from
Mar 27, 2015

Conversation

doelleri
Copy link
Contributor

For #259.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.11%) to 95.66% when pulling 9e67d12 on doelleri:sorting into 324c4ab on cfpb:milestone8.

<th scope="col" class="county_code">County Code</th>
<th scope="col" class="census_tract">Census Tract</th>
<th scope="col" class="recommended col-group-first">MSA/MD</th>
<th scope="col" role="columnheader" class="id" ng-class="{'cf-icon icon-up': sortedBy === 'properties[\'LAR number\']' && !reverse, 'cf-icon icon-down': sortedBy === 'properties[\'LAR number\']' && reverse}" ng-click="sort('properties[\'LAR number\']')" ng-attr-aria-sort="{{isSortedBy('properties[\'LAR number\']')}}">LAR Number</th>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use role="columnheader" here because we are already conveying the same information by using <th scope="col".
ref: http://www.w3.org/TR/wai-aria/roles#columnheader

Can we move the logic for setting the class to the pagination controller?

Why do we need to use ng-attr-aria-sort instead of just the aria-sort attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to http://stackoverflow.com/questions/24863531/using-aria-sort-in-validated-html5 and possibly http://www.w3.org/TR/wai-aria/states_and_properties#aria-sort but it's harder for me to interpret, role="columnheader" is needed despite scope="col".

I can move it to the controller but wasn't sure how much of an advantage it would gain.

Guess I didn't need the ng-attr-, whoops.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the SO article about the use of columnheader. I agree though with the comment on the approved answer that the implementation is broken and table's should be considered data tables by default. But that's a different fight.
In the meantime, it does mean that you need to add a role="grid" attr to your table element and a role="row" to the tr's in your table header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some helpers in eaea592 and removed ng-attr in 9ab06c3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added additional roles in 9cd2976

@coveralls
Copy link

Coverage Status

Coverage increased (+0.14%) to 95.68% when pulling eaea592 on doelleri:sorting into 324c4ab on cfpb:milestone8.

@@ -26,23 +28,48 @@ module.exports = /*@ngInject*/ function ($scope, $routeParams, $location, $http,
$scope.error = {};
}

$scope.sort = function(property) {
$scope.reverse = $scope.sortedBy === property ? !$scope.reverse : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$scope.reverse seems like an odd variable name. What is this actually tracking?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I named it reverse because that's what Angular calls it in their orderBy filter. I can rename it to something like sortAsc if you think that makes more sense.

Alternatively, I can group sortedBy and reverse in an object, and possibly rename sortedBy to orderBy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh...so reverse is supposed to indicate the direction of the sort by inferring that it is either in a reverse sort or not. That's backwards. :(
If that's the case, then I think sortAsc makes the most sense.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.14%) to 95.68% when pulling 9cd2976 on doelleri:sorting into 324c4ab on cfpb:milestone8.

poorgeek added a commit that referenced this pull request Mar 27, 2015
@poorgeek poorgeek merged commit 6447f8d into cfpb:milestone8 Mar 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants