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 call to track function on entity list component template #27114

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</tr>
</thead>
<tbody>
@for (user of users(); track trackIdentity) {
@for (user of users(); track trackIdentity(user)) {
<tr>
<td>
<a [routerLink]="['./', user.login, 'view']">{{ user.id }}</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class UserManagementComponent implements OnInit {
this.userService.update({ ...user, activated: isActivated }).subscribe(() => this.loadAll());
}

trackIdentity(_index: number, item: User): <%= this.getTypescriptKeyType(user.primaryKey.type) %> {
trackIdentity(item: User): <%= this.getTypescriptKeyType(user.primaryKey.type) %> {
return item.id!;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ export default class UserManagementComponent implements OnInit {

private onSuccess(users: User[] | null<% if (!databaseTypeCassandra) { %>, headers: HttpHeaders<% } %>): void {
<%_ if (!databaseTypeCassandra) { _%>
this.totalItems.set(Number(headers.get('X-Total-Count')));
this.totalItems.set(Number(headers.get('X-Total-Count')));
<%_ } _%>
this.users.set(users);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</tr>
</thead>
<tbody<% if (paginationInfiniteScroll) { %> infinite-scroll (scrolled)="loadNextPage()" [infiniteScrollDisabled]="!hasMorePage()" [infiniteScrollDistance]="0"<% } %>>
@for (<%= entityInstance %> of <%= entityInstancePlural %>; track track<%= primaryKey.nameCapitalized %>) {
@for (<%= entityInstance %> of <%= entityInstancePlural %>; track track<%= primaryKey.nameCapitalized %>(<%= entityInstance %>)) {
<tr data-cy="entityTable">
<%_
const routerLink = ` [routerLink]="['/${ entityPage }', ${entityInstance}.${primaryKey.name}, 'view']"`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('<%= entityAngularName %> Management Component', () => {
it('Should forward to <%= entityInstance %>Service', () => {
const entity = <%- this.generateTestEntityPrimaryKey(primaryKey, 0) %>;
jest.spyOn(service, 'get<%= entityAngularName %>Identifier');
const <%= primaryKey.name %> = comp.track<%= primaryKey.nameCapitalized %>(0, entity);
const <%= primaryKey.name %> = comp.track<%= primaryKey.nameCapitalized %>(entity);
expect(service.get<%= entityAngularName %>Identifier).toHaveBeenCalledWith(entity);
expect(<%= primaryKey.name %>).toBe(entity.<%= primaryKey.name %>);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class <%= componentName %> implements OnInit {
protected ngZone = inject(NgZone);
<%_ if (primaryKey) { _%>

track<%= primaryKey.nameCapitalized %> = (_index: number, item: I<%= entityAngularName %>): <%= primaryKey.tsType %> => this.<%= entityInstance %>Service.get<%= entityAngularName %>Identifier(item);
track<%= primaryKey.nameCapitalized %> = (item: I<%= entityAngularName %>): <%= primaryKey.tsType %> => this.<%= entityInstance %>Service.get<%= entityAngularName %>Identifier(item);
<%_ } _%>

ngOnInit(): void {
Expand Down
Loading