Commits

Alexandre Vryghem authored 59197cff2d6
108555: Refactored ItemSelectComponent to not call canSelect every time changes are detected
No tags

src/app/shared/object-select/item-select/item-select.component.html

Modified
10 10 <table id="item-select" class="table table-striped table-hover">
11 11 <thead>
12 12 <tr>
13 13 <th></th>
14 14 <th *ngIf="!hideCollection" scope="col">{{'item.select.table.collection' | translate}}</th>
15 15 <th scope="col">{{'item.select.table.author' | translate}}</th>
16 16 <th scope="col">{{'item.select.table.title' | translate}}</th>
17 17 </tr>
18 18 </thead>
19 19 <tbody>
20 - <tr *ngFor="let item of itemsRD?.payload?.page">
21 - <td><input [disabled]="!(canSelect(item) | async)" class="item-checkbox" [ngModel]="getSelected(item.id) | async" (change)="switch(item.id)" type="checkbox" name="{{item.id}}"></td>
20 + <tr *ngFor="let selectItem of selectItems$ | async">
21 + <td><input [disabled]="(selectItem.canSelect$ | async) === false" class="item-checkbox" [ngModel]="selectItem.selected$ | async" (change)="switch(selectItem.dso.id)" type="checkbox" name="{{selectItem.dso.id}}"></td>
22 22 <td *ngIf="!hideCollection">
23 - <span *ngVar="(item.owningCollection | async)?.payload as collection">
23 + <span *ngVar="(selectItem.dso.owningCollection | async)?.payload as collection">
24 24 <a *ngIf="collection" [routerLink]="['/collections', collection?.id]">
25 25 {{ dsoNameService.getName(collection) }}
26 26 </a>
27 27 </span>
28 28 </td>
29 - <td><span *ngIf="item.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{item.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
30 - <td><a [routerLink]="[(itemPageRoutes$ | async)[item.id]]">{{ dsoNameService.getName(item) }}</a></td>
29 + <td><span *ngIf="selectItem.dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{selectItem.dso.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
30 + <td><a [routerLink]="selectItem.route">{{ dsoNameService.getName(selectItem.dso) }}</a></td>
31 31 </tr>
32 32 </tbody>
33 33 </table>
34 34 </div>
35 35 </ds-pagination>
36 36 <div *ngIf="itemsRD?.payload?.totalElements === 0 || itemsRD?.payload?.page?.length === 0" class="alert alert-info w-100" role="alert">
37 37 {{'item.select.empty' | translate}}
38 38 </div>
39 39 <ds-error *ngIf="itemsRD?.hasFailed" message="{{'error.items' | translate}}"></ds-error>
40 40 <ds-themed-loading *ngIf="!itemsRD || itemsRD?.isLoading" message="{{'loading.items' | translate}}"></ds-themed-loading>

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut