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(react-grid): correlate sorting order with grouping order #414

Merged
merged 8 commits into from
Oct 18, 2017
Merged

fix(react-grid): correlate sorting order with grouping order #414

merged 8 commits into from
Oct 18, 2017

Conversation

kvet
Copy link
Contributor

@kvet kvet commented Oct 17, 2017

fixes #398

BREAKING CHANGES:

The scope parameter of the setColumnSorting action has been removed
 
The GroupingState plugin now has an optional dependency on the SortingState plugin. So, GroupingState should be placed after SortingState.

Before:

<GroupingState /* ... */ />
<SortingState /* ... */ />

After:

<SortingState /* ... */ />
<GroupingState /* ... */ />

];
let nextSorting = [];
if (keepOther === true) {
nextSorting = sorting.slice();
Copy link
Contributor

Choose a reason for hiding this comment

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

Check case when seamless immutable is used. Probably, sorting.slice() should be replaced to Array.from.

this.cancelGroupingChange = this.applyReducer.bind(this, cancelGroupingChange);
this.setColumnSorting = this.setColumnSorting.bind(this);
}
getState() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's strange that 'get' function creates a new object on each call.

this.setState(nextState);

const { onGroupingChange } = this.props;
if (onGroupingChange && nextState.grouping !== state.grouping) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nextState.grouping, nextState.expandedGroups can be replaced to const { grouping, expandedGroups } = nextState;

@@ -64,7 +64,7 @@ tableHeaderRows | Getter | Array&lt;[TableRow](table-view.md#table-row)&gt; | He
sorting | Getter | Array&lt;[Sorting](sorting-state.md#sorting)&gt; | Column sorting.
columns | Getter | Array&lt;[Column](#column)&gt; | Table columns.
grouping | Getter | Array&lt;[Grouping](grouping-state.md#grouping)&gt; | Columns used for grouping.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean, cancel: boolean }) => void | Changes column sorting.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean | Array&lt;String&gt;, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be keeped when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

keeped => kept

@kvet kvet requested a review from viterobk October 18, 2017 09:15
{ columnName: 'test', direction: 'asc' },
{ columnName: 'test3', direction: 'asc' },
]);
it('should set corretct sorting if sortIndex is specified', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: 'corretct'

@@ -89,7 +89,7 @@ columns | Getter | Array&lt;[Column](#column)&gt; | Grid columns.
draftGrouping | Getter | Array&lt;[DraftGrouping](grouping-state.md#draft-grouping)&gt; | Grouping options used for the preview.
sorting | Getter | Array&lt;[Sorting](sorting-state.md#sorting)&gt; | The current sorting state.
groupByColumn | Action | ({ columnName: string }) => void | Toggles a column's grouping state.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean, cancel: boolean }) => void | Updates column sorting.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean | Array&lt;String&gt;, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check this sentence

The keepOther can handle contains the names...

@@ -55,6 +55,8 @@ A string value that consists of values by which rows are grouped, separated by t
Name | Plugin | Type | Description
-----|--------|------|------------
columns | Getter | Array&lt;[Column](grid.md#column)&gt; | The grid columns.
sorting? | Getter | Array&lt;[Sorting](sorting-state.md#sorting)&gt; | Applied column sorting.
setColumnSorting? | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean | Array&lt;String&gt;, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

can handle contains

@@ -40,4 +40,4 @@ none
Name | Plugin | Type | Description
-----|--------|------|------------
sorting | Getter | Array&lt;[Sorting](#sorting)&gt; | Applied column sorting.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean, cancel: boolean, scope: Array&lt;String&gt; }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. Cancels sorting by the current column if `cancel` is set to `true`. The `scope` array contains the names of columns taken into account when sorting.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean | Array&lt;String&gt;, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

can handle contains

@@ -64,7 +64,7 @@ tableHeaderRows | Getter | Array&lt;[TableRow](table-view.md#table-row)&gt; | He
sorting | Getter | Array&lt;[Sorting](sorting-state.md#sorting)&gt; | Column sorting.
columns | Getter | Array&lt;[Column](#column)&gt; | Table columns.
grouping | Getter | Array&lt;[Grouping](grouping-state.md#grouping)&gt; | Columns used for grouping.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean, cancel: boolean }) => void | Changes column sorting.
setColumnSorting | Action | ({ columnName: string, direction: 'asc' &#124; 'desc', keepOther: boolean | Array&lt;String&gt;, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

can handle contains

expect(defaultDeps.action.setCurrentPage.mock.calls)
.toEqual([[2]]);
expect(defaultDeps.action.setCurrentPage.mock.calls[0][0])
.toEqual(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the .toHaveBeenCalledWith() matcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Action is called with additional arguments (getters and actions)

@kvet kvet merged commit db3377c into DevExpress:master Oct 18, 2017
@kvet kvet deleted the sorting-with-grouping branch October 18, 2017 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TableHeaderRow does not cancel applied sorting within a scope
4 participants