Skip to content

feat(data-table): add trackby input #5097

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

Merged
merged 7 commits into from
Jun 23, 2017

Conversation

andrewseguin
Copy link
Contributor

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 12, 2017
Copy link

@ErinCoughlan ErinCoughlan left a comment

Choose a reason for hiding this comment

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

LGTM


<span>Track By</span>
<md-radio-group [(ngModel)]="trackBy">
<md-radio-button [value]="'id'"> ID </md-radio-button>

Choose a reason for hiding this comment

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

Why are there extra spaces around the text?

@@ -7,13 +7,13 @@ import {
ContentChildren,
Directive,
ElementRef,
Input,
Input, isDevMode,

Choose a reason for hiding this comment

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

Should these be on new lines?


constructor() {
for (let i = 0; i < 100; i++) { this.addPerson(); }
}

randomize(changeReferences: boolean) {
Copy link
Member

Choose a reason for hiding this comment

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

randomize -> shuffle

@@ -138,6 +138,119 @@ describe('CdkTable', () => {
expect(changedRows[2].getAttribute('initialIndex')).toBe(null);
});

describe('should properly use trackBy when diffing to add/remove/move rows', () => {
Copy link
Member

Choose a reason for hiding this comment

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

The describe can just be with trackBy (only individual tests are should...)

`
})
class TrackByCdkTableApp {
static TRACK_BY: 'reference' | 'propertyA' | 'index' = 'reference';
Copy link
Member

Choose a reason for hiding this comment

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

Why is this static?

Also, even if it is static, CAPS_CASE is for constants (which this isn't)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot be a component property because the trackBy function does not run in the context of the component (cannot use this). Fixed the caps case, thought I saw a lint error regarding the format, but I must have confused it with a different property.

Static because the trackBy function does not have this as TrackByCdkTableApp so it cannot be

TrackByCdkTableApp.TRACK_BY = 'reference';
});

function createComponent() {
Copy link
Member

Choose a reason for hiding this comment

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

createTestComponentWithTrackyByTable?

}

// Swap first two elements, remove the third, add new data
function changeData() {
Copy link
Member

Choose a reason for hiding this comment

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

mutateTableData?

@andrewseguin
Copy link
Contributor Author

Addressed the comments, thanks for the review.

@andrewseguin andrewseguin force-pushed the table-track-by branch 3 times, most recently from 6248287 to a11e70f Compare June 19, 2017 19:05
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM, one formatting nit

Add merge-ready when done

@@ -21,7 +21,12 @@ describe('CdkTable', () => {

TestBed.configureTestingModule({
imports: [CdkDataTableModule],
declarations: [SimpleCdkTableApp, DynamicDataSourceCdkTableApp, CustomRoleCdkTableApp],
declarations: [
SimpleCdkTableApp,
Copy link
Member

Choose a reason for hiding this comment

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

-2 indent

@andrewseguin
Copy link
Contributor Author

Indention fixed - added merge-ready

@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Jun 21, 2017
@andrewseguin
Copy link
Contributor Author

PR has been rebased

@jelbourn jelbourn merged commit c81e608 into angular:master Jun 23, 2017
@andrewseguin andrewseguin deleted the table-track-by branch November 28, 2017 20:35
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants