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

feat(stark-ui): table - add support for angular CDK selection model #1377

Conversation

SuperITMan
Copy link
Member

ISSUES CLOSED: #1366

Disabled changeDetection strategy in Stark Table from 'OnPush' to 'Default' in order to
fix selection issues.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[X] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The developer cannot manage the Stark Table selection programmatically.

Issue Number: #1366

What is the new behavior?

New selection Input has been added to allow the developer to obtain all the features proposed by the selection model object provided by/in angular/material.

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

@dsebastien
Copy link
Contributor

+1 for a good night's sleep ;-)

@SuperITMan SuperITMan force-pushed the feature/table-add-selection-input branch from 66d03a7 to c3b8d7f Compare August 7, 2019 08:52
@SuperITMan SuperITMan changed the title feat(stark-ui): table - add support for NG CDK selection model. feat(stark-ui): table - add support for NG CDK selection model Aug 7, 2019
@SuperITMan SuperITMan force-pushed the feature/table-add-selection-input branch 3 times, most recently from f5cbee4 to e42aa14 Compare August 7, 2019 09:51
Copy link
Contributor

@nicanac nicanac left a comment

Choose a reason for hiding this comment

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

LGTM :-)

@SuperITMan SuperITMan changed the title feat(stark-ui): table - add support for NG CDK selection model feat(stark-ui): table - add support for angular CDK selection model Aug 7, 2019
Copy link
Collaborator

@carlo-nomes carlo-nomes left a comment

Choose a reason for hiding this comment

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

A couple of notes, also are we not deprecating the old api for the table? If yes, maybe we should also show a warning for that.

}

public set selection(selection: SelectionModel<object>) {
if (coerceBooleanProperty(this.multiSelect) || !!this.rowsSelectable) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we make multiselect a boolean with a coerce setter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, we had a method called isMultiSelectEnabled() which contained:

return coerceBooleanProperty(this.multiSelect);

Maybe could we do this in another PR to improve the table component ? 😊

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I agree, cause it's not really related to this issue.

const i: number = this.displayedColumns.indexOf("select");
this.displayedColumns.splice(i);
if (this.rowsSelectable) {
if (!this.displayedColumns.includes("select")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you combine these if statements

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not a big fan of combining those 2 if statements.
What would happen if rowsSelectable is set twice to true (true or "true" or 1 using any cast) ?
The "select" displayedColumn would be deleted even it's not the goal...

What do you think ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes, I missed that there is a third "else do nothing" clause and I kind of missed what the code was doing.
If I may suggest a small refactor. But that's mostly preference, so I won't block the PR for this.

const i = this.displayedColumns.indexOf("select");

// Show column
if (this.rowsSelectable && i === -1) {
  this.displayedColumns.unshift("select");
}

// Hide column
if (!this.rowsSelectable && i >= 0) {
  this.displayedColumns.splice(i);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

For the rc.1, I'll do a PR to cleanup a bit the table component 😊

@SuperITMan SuperITMan force-pushed the feature/table-add-selection-input branch 2 times, most recently from e060da3 to 19c1731 Compare August 7, 2019 14:16
@coveralls
Copy link

coveralls commented Aug 7, 2019

Coverage Status

Coverage increased (+0.02%) to 95.392% when pulling a20da4f on SuperITMan:feature/table-add-selection-input into 2c8d661 on NationalBankBelgium:master.

ISSUES CLOSED: #1366

Disabled changeDetection strategy in Stark Table from 'OnPush' to 'Default' in order to fix selection issues.
Deprecated 'multiSelect', 'rowsSelectable' Input and 'selectChanged'
Output in favor of the new 'selection' Input.
@SuperITMan SuperITMan force-pushed the feature/table-add-selection-input branch from 19c1731 to a20da4f Compare August 7, 2019 14:58
@SuperITMan SuperITMan merged commit 52e2ec9 into NationalBankBelgium:master Aug 8, 2019
@SuperITMan SuperITMan deleted the feature/table-add-selection-input branch August 8, 2019 07:14
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.

ui: table - selection is not reset when data changes
5 participants