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

fix(core): Sort Priority Zero Based #4807

Merged
merged 1 commit into from Jan 22, 2016

Conversation

JLLeitschuh
Copy link
Contributor

Before sort priority was a mix of 0 and 1 based.
You could create columns with a sort priority of zero but once the user
clicked on a column to sort it its index would change to 1. There was no
way for the sort index to return to 0 from within the grid's menus.
This mix of 0 and 1 based sorting was confusing and created UI problems
when displaying the sort index in the column header.

Closes #4685
BREAKING CHANGE:
GridOptions.columnDef.sort.priority now expects the lowest value
to be 0.
The Grid Header will display a sort priority of 0 as 1.
Using if(col.sort.priority) to determine if a column is sorted is no
longer valid as 0 == false.
Saved grid objects may be affected by this.

@JLLeitschuh JLLeitschuh added this to the 3.1 milestone Dec 3, 2015
@JLLeitschuh
Copy link
Contributor Author

This has a breaking change. It would be good to do a version bump to 3.1.0 after this is merged.

@@ -1876,12 +1876,12 @@ angular.module('ui.grid')
p = 0;

self.columns.forEach(function (col) {
if (col.sort && col.sort.priority && col.sort.priority > p) {
p = col.sort.priority;
if (col.sort && col.sort.priority !== 'undefined' && col.sort.priority >= p) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here you should compare col.sort.priority to undefined and not 'undefined' or typeof col.sort.priority !== 'undefined'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'll change that. I saw it like this somewhere else.

@swalters
Copy link
Contributor

@JLLeitschuh can you fix the merge issues? I think we need to get this merged and released as soon as we can. thanks.

@JLLeitschuh
Copy link
Contributor Author

Yea, I'll try to fix this today.

Before sort priority was a mix of 0 and 1 based.
You could create columns with a sort priority of zero but once the user
clicked on a column to sort it its index would change to 1. There was no
way for the sort index to return to 0 from within the grid's menus.
This mix of 0 and 1 based sorting was confusing and created UI problems
when displaying the sort index in the column header.

Closes angular-ui#4685
BREAKING CHANGE:
**GridOptions.columnDef.sort.priority** now expects the lowest value
to be 0.
The Grid Header will display a sort priority of 0 as 1.
Using `if(col.sort.priority)` to determine if a column is sorted is no
longer valid as `0 == false`.
Saved grid objects may be affected by this.
swalters added a commit that referenced this pull request Jan 22, 2016
@swalters swalters merged commit 798cb07 into angular-ui:master Jan 22, 2016
@@ -21,13 +21,13 @@
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="{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + col.sort.priority : null}}"
title="{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + ( col.sort.priority + 1 ) : null}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

In Grid.js line 1880 aren't you bumping up the sortPriority, so adding 1 again here would be incorrect?

swalters added a commit that referenced this pull request Jan 22, 2016
ShayArtzi pushed a commit to ShayArtzi/ui-grid that referenced this pull request Jan 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants