Skip to content

Commit ed63b75

Browse files
authored
Merge pull request #5551 from guillermo-escire/feature/5542
fix #5542: display Primary badge on Download button component for pri…
2 parents 8c1fe8a + 974d5ec commit ed63b75

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

src/app/shared/bitstream-attachment/bitstream-attachment.component.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
<div class="order-lg-3 ml-auto">
99
<div class="d-flex flex-column align-items-end gap-3">
1010
<div class="text-nowrap">
11-
<div class="text-nowrap">
12-
<ds-file-download-button [bitstream]="attachment" [item]="item"></ds-file-download-button>
13-
</div>
11+
<ds-file-download-button [bitstream]="attachment" [item]="item"></ds-file-download-button>
1412
</div>
13+
@if (primaryBitstreamId === attachment.id) {
14+
<span class="badge bg-primary">
15+
{{ 'item.page.bitstreams.primary' | translate }}
16+
</span>
17+
}
1518
</div>
1619
</div>
1720

src/app/shared/bitstream-attachment/bitstream-attachment.component.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,18 @@ describe('BitstreamAttachmentComponent', () => {
9898
expect(component.checksumInfo.value).toBe('abc123');
9999
expect(component.allAttachmentProviders).toEqual(['provider1']);
100100
});
101+
102+
it('should display the primary badge when primaryBitstreamId matches attachment id', () => {
103+
component.primaryBitstreamId = attachmentMock.id;
104+
fixture.detectChanges();
105+
const badge = fixture.nativeElement.querySelector('.badge.bg-primary');
106+
expect(badge).toBeTruthy();
107+
});
108+
109+
it('should not display the primary badge when primaryBitstreamId does not match', () => {
110+
component.primaryBitstreamId = 'other-id';
111+
fixture.detectChanges();
112+
const badge = fixture.nativeElement.querySelector('.badge.bg-primary');
113+
expect(badge).toBeNull();
114+
});
101115
});

src/app/shared/bitstream-attachment/bitstream-attachment.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export class BitstreamAttachmentComponent implements OnInit {
8989
*/
9090
@Input() item: Item;
9191

92+
/**
93+
* The ID of the primary bitstream, used to display the Primary badge
94+
*/
95+
@Input() primaryBitstreamId: string;
96+
9297
/**
9398
* Format of the bitstream
9499
*/

src/app/shared/bitstream-attachment/section/attachment-section.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="file-section">
66

77
@for (file of bitstreams; track file) {
8-
<ds-bitstream-attachment [item]="item" [attachment]="file"></ds-bitstream-attachment>
8+
<ds-bitstream-attachment [item]="item" [attachment]="file" [primaryBitstreamId]="primaryBitstreamId"></ds-bitstream-attachment>
99
}
1010
@if (isLoading) {
1111
<ds-loading message="{{'loading.default' | translate}}" [showMessage]="false"></ds-loading>

0 commit comments

Comments
 (0)