Skip to content
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

Conversation

weltenwort
Copy link
Member

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.
Copy link
Member

@lukasolson lukasolson left a 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.

Copy link
Contributor

@stacey-gammon stacey-gammon left a 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) {
Copy link
Contributor

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?

Copy link
Member Author

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!

@weltenwort
Copy link
Member Author

@stacey-gammon I implemented your suggestion. Are you fine with the way that looks?

@weltenwort weltenwort merged commit 6e4ee6f into elastic:master Apr 3, 2017
weltenwort added a commit to weltenwort/kibana that referenced this pull request Apr 3, 2017
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.
weltenwort added a commit that referenced this pull request Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants