-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Factor out sorting in the doc table #10924
Factor out sorting in the doc table #10924
Conversation
This refactoring effort turns the implicit manipulation of the sort order, that was performed inline in the table header, into explicit calls to functions provided by the parent of the `<doc-table>` directive. It thereby separates presentation logic from business logic and prepares the directive for further refactorings. Additionally, the parent can now control whether sorting is allowed at all by either implementing custom logic in the `onSortOrderChange` handler or by leaving it out completely. In the latter case the sorting controls will be completely hidden from the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for cleaning this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
@@ -117,6 +117,10 @@ uiModules | |||
$scope.$watchCollection('panel.sort', function () { | |||
$scope.saveState(); | |||
}); | |||
|
|||
$scope.setSortOrder = function setSortOrder(columnName, direction) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can get rid of the watch above if we move $scope.saveState()
in here. As long as the state is updated from the initial setting above. Do you think getting rid of the watch would increase readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good idea. Looks like that's the only place where the sorting can be changed. It wouldn't just improve readability but also performance (fewer evaluations during digest). Thank you!
@stacey-gammon I implemented your suggestion. Are you fine with the way that looks? |
This refactoring effort turns the implicit manipulation of the sort order, that was performed inline in the table header, into explicit calls to functions provided by the parent of the `<doc-table>` directive. It thereby separates presentation logic from business logic and prepares the directive for further refactorings. Additionally, the parent can now control whether sorting is allowed at all by either implementing custom logic in the `onSortOrderChange` handler or by leaving it out completely. In the latter case the sorting controls will be completely hidden from the header.
This refactoring effort turns the implicit manipulation of the sort
order, that was performed inline in the table header, into explicit
calls to functions provided by the parent of the
<doc-table>
directive. It thereby separates presentation logic from business logic
and prepares the directive for further refactorings.
Additionally, the parent can now control whether sorting is allowed at
all by either implementing custom logic in the
onSortOrderChange
handler or by leaving it out completely. In the latter case the sorting
controls will be completely hidden from the header.