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

Refactored columnSorting plugin - stage 2 #5228

Merged
merged 12 commits into from
Jul 4, 2018
Merged

Conversation

wszymanski
Copy link
Contributor

Context

How has this been tested?

Manual tests on column sorting, including changing the order of columns.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature or improvement (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Additional language file or change to the existing one (translations)

Related issue(s):

  1. Refactor of columnSorting plugin - stage 2 #5064
  2. sortIndicator is not updated after moving the columns #3900

Checklist:

  • My code follows the code style of this project,
  • My change requires a change to the documentation.

@wszymanski wszymanski added this to the July 2018 milestone Jul 3, 2018
sort(column, order) {
this.setSortingColumn(column, order);
sort(column, order = this.getNextOrderState(column)) {
const allowSorting = this.hot.runHooks('beforeColumnSort', column, order);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to run a hook, even if a column is undefined?

}
}

return ASC_SORT_STATE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use return once? With the cached result in a variable.
@budnix mentioned that will be useful when we implement automatic code coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For discussion with @jansiegel. I will remember that.

const sortFunction = this.getSortFunctionForColumn(columnMeta);
const visualColumn = this.hot.toVisualColumn(this.sortColumn);
const columnMeta = this.hot.getCellMeta(0, visualColumn);
const sortFunction = getSortFunctionForColumn(columnMeta);
const emptyRows = this.hot.countEmptyRows();
let nrOfRows;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe nrOfRows could be const?

return column;
};

const hot = handsontable({
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use only handsontable({}).

getPlugin('ColumnSorting').sort(0, 'asc');

// changing column order: 0 <-> 1
hot.updateSettings({modifyCol});
Copy link
Contributor

Choose a reason for hiding this comment

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

Just updateSettings() should be called in proper context.

const sortedColumn = this.$container.find('th span.columnSorting')[1];
const afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content');

expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can cache String.fromCharCode(9650) once at a very beginning, with a comment, what char it should be.

@mrpiotr-dev mrpiotr-dev assigned wszymanski and unassigned mrpiotr-dev Jul 3, 2018
@wszymanski wszymanski assigned mrpiotr-dev and unassigned wszymanski Jul 4, 2018
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.

3 participants