From badf00258c0a0fa576eb2ab3da4b0134d3e7f2b6 Mon Sep 17 00:00:00 2001 From: Kuno Vercammen Date: Fri, 15 Mar 2024 11:42:01 +0100 Subject: [PATCH] 113124: Allow opening ds-metadata-uri-values links in a new window --- .../metadata-uri-values/metadata-uri-values.component.html | 2 +- .../metadata-uri-values.component.spec.ts | 7 +++++++ .../metadata-uri-values/metadata-uri-values.component.ts | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.html b/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.html index 9091beb6c7d..7d7174536b1 100644 --- a/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.html +++ b/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.html @@ -1,5 +1,5 @@ - + {{ linktext || mdValue.value }} diff --git a/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.spec.ts b/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.spec.ts index f869ab8aaf8..56a51b01fe2 100644 --- a/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.spec.ts +++ b/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.spec.ts @@ -73,6 +73,13 @@ describe('MetadataUriValuesComponent', () => { 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', () => { beforeEach(() => { diff --git a/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.ts b/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.ts index e070eccf2d5..5a024bfb306 100644 --- a/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.ts +++ b/src/app/item-page/field-components/metadata-uri-values/metadata-uri-values.component.ts @@ -37,4 +37,10 @@ export class MetadataUriValuesComponent extends MetadataValuesComponent { * The label for this iteration of metadata values */ @Input() label: string; + + /** + * The target attribute for the metadata links. + * Defaults to '_blank' to open links in a new window/tab. + */ + @Input() linkTarget = '_blank'; }