Skip to content

Commit 8d97141

Browse files
[DSC-1520] subtype identfier configuration
1 parent 1d6edf2 commit 8d97141

7 files changed

Lines changed: 109 additions & 5 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<div [class]="field.styleValue">
2-
<span class="text-value">
3-
<a [target]="target" href="{{identifier?.href}}">{{ identifier?.text }}</a>
4-
</span>
5-
</div>
2+
<div class="d-flex align-items-center identifier-container-{{iconPosition}}">
3+
<a href="{{iconLink}}" [ngbTooltip]="iconLink" target="_blank" *ngIf="subTypeIcon && iconPosition !== iconPositionEnum.NONE">
4+
<img class="source-icon" [src]="subTypeIcon" alt="source-icon" >
5+
</a>
6+
<span class="text-value">
7+
<a [target]="target" href="{{identifier?.href}}">{{ identifier?.text }}</a>
8+
</span>
9+
</div>
10+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.source-icon {
2+
height: var(--ds-identifier-sybetype-icon-height);
3+
min-height: 16px;
4+
width: auto;
5+
}
6+
7+
.identifier-container-LEFT {
8+
flex-direction: row;
9+
.source-icon {
10+
margin-right: 0.2em;
11+
}
12+
}
13+
14+
.identifier-container-RIGHT {
15+
flex-direction: row-reverse;
16+
justify-content: flex-end;
17+
.source-icon {
18+
margin-left: 0.2em;
19+
}
20+
}

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/identifier/identifier.component.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import { IdentifierSubtypesConfig, IdentifierSubtypesIconPositionEnum } from './../../../../../../../../config/identifier-subtypes-config.interface';
12
import { Component, Inject, OnInit } from '@angular/core';
23
import { FieldRenderingType, MetadataBoxFieldRendering } from '../metadata-box.decorator';
34
import { ResolverStrategyService } from '../../../../../../services/resolver-strategy.service';
4-
import { hasValue, isNotEmpty } from '../../../../../../../shared/empty.util';
5+
import { hasNoValue, hasValue, isNotEmpty } from '../../../../../../../shared/empty.util';
56
import { MetadataLinkValue } from '../../../../../../models/cris-layout-metadata-link-value.model';
67
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model';
78
import { Item } from '../../../../../../../core/shared/item.model';
89
import { TranslateService } from '@ngx-translate/core';
910
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
1011
import { MetadataValue } from '../../../../../../../core/shared/metadata.models';
12+
import { environment } from 'src/environments/environment';
1113

1214
/**
1315
* This component renders the identifier metadata fields.
@@ -37,6 +39,31 @@ export class IdentifierComponent extends RenderingTypeValueModelComponent implem
3739
*/
3840
target = '_blank';
3941

42+
/**
43+
* The identifier subtype configurations
44+
*/
45+
identifierSubtypeConfig: IdentifierSubtypesConfig[] = environment.identifierSubtypes;
46+
47+
/**
48+
* The icon to display for the identifier subtype
49+
*/
50+
subTypeIcon: string;
51+
52+
/**
53+
* The position of the icon relative to the identifier
54+
*/
55+
iconPosition: IdentifierSubtypesIconPositionEnum = IdentifierSubtypesIconPositionEnum.NONE;
56+
57+
/**
58+
* The link to navigate to when the icon is clicked
59+
*/
60+
iconLink = '';
61+
62+
/**
63+
* The identifier subtype to render
64+
*/
65+
iconPositionEnum = IdentifierSubtypesIconPositionEnum;
66+
4067
constructor(
4168
@Inject('fieldProvider') public fieldProvider: LayoutField,
4269
@Inject('itemProvider') public itemProvider: Item,
@@ -102,5 +129,28 @@ export class IdentifierComponent extends RenderingTypeValueModelComponent implem
102129

103130
ngOnInit(): void {
104131
this.identifier = this.getIdentifierFromValue();
132+
this.getSubtypeValue();
133+
}
134+
135+
/**
136+
* Retrieves the subtype value for the identifier component.
137+
* If the identifier subtype is not empty, it searches for the subtype with a matching name to the rendering subtype.
138+
* If a matching subtype is found, it sets the icon position, subtype icon, and icon link based on the subtype's properties.
139+
*/
140+
private getSubtypeValue() {
141+
if (isNotEmpty(this.identifierSubtypeConfig)) {
142+
const subtypeVal = this.identifierSubtypeConfig.find((subtype) => subtype.name === this.renderingSubType);
143+
if (hasNoValue(subtypeVal)) {
144+
return;
145+
}
146+
147+
this.iconPosition = subtypeVal.iconPosition;
148+
this.subTypeIcon = subtypeVal.iconPosition !== IdentifierSubtypesIconPositionEnum.NONE ? subtypeVal?.icon : '';
149+
this.iconLink = subtypeVal?.link;
150+
}
105151
}
152+
153+
// TODO: Check the internal | external link
154+
// TODO: UNIT TESTs
155+
106156
}

src/config/app-config.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { SearchResultConfig } from './search-result-config.interface';
3434
import { MiradorConfig } from './mirador-config.interfaces';
3535
import { LoaderConfig } from './loader-config.interfaces';
3636
import { MetaTagsConfig } from './meta-tags.config';
37+
import { IdentifierSubtypesConfig } from './identifier-subtypes-config.interface';
3738

3839
interface AppConfig extends Config {
3940
ui: UIServerConfig;
@@ -74,6 +75,7 @@ interface AppConfig extends Config {
7475
mirador: MiradorConfig;
7576
loader: LoaderConfig;
7677
metaTags: MetaTagsConfig;
78+
identifierSubtypes: IdentifierSubtypesConfig[];
7779
}
7880

7981
/**

src/config/default-app-config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { SearchResultConfig } from './search-result-config.interface';
3737
import { MiradorConfig } from './mirador-config.interfaces';
3838
import { LoaderConfig } from './loader-config.interfaces';
3939
import { MetaTagsConfig } from './meta-tags.config';
40+
import { IdentifierSubtypesConfig, IdentifierSubtypesIconPositionEnum } from './identifier-subtypes-config.interface';
4041

4142
export class DefaultAppConfig implements AppConfig {
4243
production = false;
@@ -803,4 +804,13 @@ export class DefaultAppConfig implements AppConfig {
803804
'It is compliant with and supports key international standards, facilitating interoperability and data transfer.\n' +
804805
'DSpace-CRIS enables secure, integrated and interoperable research information and data management – in a single solution.'
805806
};
807+
808+
identifierSubtypes: IdentifierSubtypesConfig[] = [
809+
{
810+
name: 'ror',
811+
icon: 'assets/images/ror.logo.icon.svg',
812+
iconPosition: IdentifierSubtypesIconPositionEnum.LEFT,
813+
link: 'https://ror.org'
814+
}
815+
];
806816
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Represents the configuration for identifier subtypes.
3+
*/
4+
export interface IdentifierSubtypesConfig {
5+
name: string; // The name of the identifier subtype
6+
icon: string; // The icon to display for the identifier subtype
7+
iconPosition: IdentifierSubtypesIconPositionEnum; // The position of the icon relative to the identifier
8+
link: string; // The link to navigate to when the icon is clicked
9+
}
10+
11+
export enum IdentifierSubtypesIconPositionEnum {
12+
NONE = 'NONE',
13+
LEFT = 'LEFT',
14+
RIGHT = 'RIGHT',
15+
}

src/styles/_custom_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,6 @@
145145

146146
--ds-comcol-logo-max-width: 500px;
147147
--ds-comcol-logo-max-height: 500px;
148+
149+
--ds-identifier-sybetype-icon-height: 24px;
148150
}

0 commit comments

Comments
 (0)