Skip to content

Commit 055fa22

Browse files
authored
Merge pull request #5665 from alexandrevryghem/w2p-141473_fix-irregular-whitespace-for-MetadataRepresentationListComponent_contribute-main
Fix irregular whitespace for MetadataRepresentationListComponent
2 parents 1995432 + cc05cfb commit 055fa22

3 files changed

Lines changed: 40 additions & 21 deletions

File tree

src/app/item-page/simple/metadata-representation-list/metadata-representation-list.component.html

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
<ds-metadata-field-wrapper [label]="label">
2-
@for (objectPage of objects; track objectPage; let i = $index) {
2+
@for (objectPage of objects; track objectPage; let i = $index; let lastPage = $last) {
33
<ng-container *ngVar="(objectPage | async) as representations">
4-
@for (rep of representations; track rep) {
5-
<ds-metadata-representation-loader
6-
[mdRepresentation]="rep">
7-
</ds-metadata-representation-loader>
4+
@for (rep of representations; track rep; let last = $last) {
5+
<div class="d-inline">
6+
<ds-metadata-representation-loader [mdRepresentation]="rep"
7+
class="d-inline-block">
8+
</ds-metadata-representation-loader>
9+
@if (!last || !lastPage) {
10+
<span [innerHTML]="separator"></span>
11+
}
12+
</div>
813
}
9-
@if ((i + 1) === objects.length && (i > 0) && (!representations || representations?.length === 0)) {
14+
@if (lastPage && (i > 0) && (!representations || representations?.length === 0)) {
1015
<ds-loading message="{{'loading.default' | translate}}"></ds-loading>
1116
}
12-
@if ((i + 1) === objects.length && representations?.length > 0) {
13-
<div class="d-inline-block w-100 mt-2">
14-
@if ((objects.length * incrementBy) < total) {
15-
<div class="float-start">
16-
<button class="btn btn-link btn-link-inline" (click)="increase()">{{'item.page.related-items.view-more' |
17-
translate:{ amount: (total - (objects.length * incrementBy) < incrementBy) ? total - (objects.length * incrementBy) : incrementBy } }}</button>
18-
</div>
19-
}
20-
@if (objects.length > 1) {
21-
<div class="float-end">
22-
<button class="btn btn-link btn-link-inline" (click)="decrease()">{{'item.page.related-items.view-less' |
23-
translate:{ amount: representations?.length } }}</button>
24-
</div>
25-
}
17+
@if (lastPage && representations?.length > 0 && ((objects.length * incrementBy) < total || objects.length > 1)) {
18+
<div class="d-flex justify-content-between w-100 mt-2">
19+
<div>
20+
@if ((objects.length * incrementBy) < total) {
21+
<button class="btn btn-link btn-link-inline" (click)="increase()">{{'item.page.related-items.view-more' |
22+
translate:{ amount: (total - (objects.length * incrementBy) < incrementBy) ? total - (objects.length * incrementBy) : incrementBy } }}</button>
23+
}
24+
</div>
25+
<div>
26+
@if (objects.length > 1) {
27+
<button class="btn btn-link btn-link-inline" (click)="decrease()">{{'item.page.related-items.view-less' |
28+
translate:{ amount: representations?.length } }}</button>
29+
}
30+
</div>
2631
</div>
2732
}
2833
</ng-container>

src/app/item-page/simple/metadata-representation-list/metadata-representation-list.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList
7171
*/
7272
@Input() incrementBy = 10;
7373

74+
/**
75+
* The separator used to split the metadata values (can contain HTML)
76+
*/
77+
@Input() separator = '<br>';
78+
7479
/**
7580
* The total amount of metadata values available
7681
*/

src/app/item-page/simple/metadata-representation-list/themed-metadata-representation-list.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ import { MetadataRepresentationListComponent } from './metadata-representation-l
1212
templateUrl: '../../../shared/theme-support/themed.component.html',
1313
})
1414
export class ThemedMetadataRepresentationListComponent extends ThemedComponent<MetadataRepresentationListComponent> {
15-
protected inAndOutputNames: (keyof MetadataRepresentationListComponent & keyof this)[] = ['parentItem', 'itemType', 'metadataFields', 'label', 'incrementBy'];
15+
protected inAndOutputNames: (keyof MetadataRepresentationListComponent & keyof this)[] = [
16+
'parentItem',
17+
'itemType',
18+
'metadataFields',
19+
'label',
20+
'incrementBy',
21+
'separator',
22+
];
1623

1724
@Input() parentItem: Item;
1825

@@ -24,6 +31,8 @@ export class ThemedMetadataRepresentationListComponent extends ThemedComponent<M
2431

2532
@Input() incrementBy: number;
2633

34+
@Input() separator: string;
35+
2736
protected getComponentName(): string {
2837
return 'MetadataRepresentationListComponent';
2938
}

0 commit comments

Comments
 (0)