113124: Allow opening ds-metadata-uri-values links in a new window

This commit is contained in:
Kuno Vercammen
2024-03-15 11:42:01 +01:00
parent 4c693a1294
commit badf00258c
3 changed files with 14 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
<ds-metadata-field-wrapper [label]="label | translate"> <ds-metadata-field-wrapper [label]="label | translate">
<a class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;" [href]="mdValue.value"> <a class="dont-break-out" *ngFor="let mdValue of mdValues; let last=last;" [href]="mdValue.value" [target]="linkTarget">
{{ linktext || mdValue.value }}<span *ngIf="!last" [innerHTML]="separator"></span> {{ linktext || mdValue.value }}<span *ngIf="!last" [innerHTML]="separator"></span>
</a> </a>
</ds-metadata-field-wrapper> </ds-metadata-field-wrapper>

View File

@@ -73,6 +73,13 @@ describe('MetadataUriValuesComponent', () => {
expect(separators.length).toBe(mockMetadata.length - 1); expect(separators.length).toBe(mockMetadata.length - 1);
}); });
it('should contain the correct target attribute for metadata links', () => {
const links = fixture.debugElement.queryAll(By.css('a'));
for (const link of links) {
expect(link.nativeElement.getAttribute('target')).toBe('_blank');
}
});
describe('when linktext is defined', () => { describe('when linktext is defined', () => {
beforeEach(() => { beforeEach(() => {

View File

@@ -37,4 +37,10 @@ export class MetadataUriValuesComponent extends MetadataValuesComponent {
* The label for this iteration of metadata values * The label for this iteration of metadata values
*/ */
@Input() label: string; @Input() label: string;
/**
* The target attribute for the metadata links.
* Defaults to '_blank' to open links in a new window/tab.
*/
@Input() linkTarget = '_blank';
} }