Skip to content

Commit 7d1341e

Browse files
141473: Hide load more/less section completely when the buttons are hidden
1 parent bcc437d commit 7d1341e

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
@@ -72,6 +72,11 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList
7272
*/
7373
@Input() incrementBy = 10;
7474

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

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
@@ -17,7 +17,14 @@ import { MetadataRepresentationListComponent } from './metadata-representation-l
1717
],
1818
})
1919
export class ThemedMetadataRepresentationListComponent extends ThemedComponent<MetadataRepresentationListComponent> {
20-
protected inAndOutputNames: (keyof MetadataRepresentationListComponent & keyof this)[] = ['parentItem', 'itemType', 'metadataFields', 'label', 'incrementBy'];
20+
protected inAndOutputNames: (keyof MetadataRepresentationListComponent & keyof this)[] = [
21+
'parentItem',
22+
'itemType',
23+
'metadataFields',
24+
'label',
25+
'incrementBy',
26+
'separator',
27+
];
2128

2229
@Input() parentItem: Item;
2330

@@ -29,6 +36,8 @@ export class ThemedMetadataRepresentationListComponent extends ThemedComponent<M
2936

3037
@Input() incrementBy: number;
3138

39+
@Input() separator: string;
40+
3241
protected getComponentName(): string {
3342
return 'MetadataRepresentationListComponent';
3443
}

0 commit comments

Comments
 (0)