Skip to content

Commit 9116001

Browse files
FrancescoMolinarosteph-ieffam
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-1629-authority-source-porting (pull request DSpace#1618)
Task/dspace cris 2023 02 x/DSC-1629 authority source porting Approved-by: Stefano Maffei
2 parents 6538fd3 + 1a18cb3 commit 9116001

14 files changed

Lines changed: 155 additions & 5 deletions

src/app/core/submission/submission-response-parsing.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export function normalizeSectionData(obj: any, objIndex?: number) {
5151
(obj.display || obj.value),
5252
obj.place || objIndex,
5353
obj.confidence,
54-
obj.otherInformation
54+
obj.otherInformation,
55+
obj.source
5556
);
5657
} else if (Array.isArray(obj)) {
5758
result = [];

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88
<ng-template #hasInfo let-entry="entry">
99
<ul class="list-unstyled mb-0">
10-
<li class="list-item text-truncate text-primary font-weight-bold">{{entry.value}}</li>
10+
<li class="list-item d-flex align-items-center">
11+
<img *ngIf="entry.source" class="mr-2" #imgTag [src]="getAuthoritySourceIcon(entry.source, imgTag)" [attr.alt]="('form.entry.source.' + entry.source) | translate" />
12+
<div class="text-truncate text-primary font-weight-bold">{{entry.value}}</div>
13+
<div *ngIf="entry.source" class="ml-2 text-truncate text-secondary">{{ ('form.entry.source.' + entry.source) | translate}}</div>
14+
</li>
1115
<ng-container *ngFor="let item of entry.otherInformation | dsObjNgFor">
1216
<li *ngIf="!item.key.startsWith('data-')" class="list-item text-truncate text-secondary" >
1317
{{ 'form.other-information.' + item.key | translate }} : {{item.value !== '' ? getOtherInfoValue(item.value, item.key) : ('form.other-information.not-available' | translate)}}
@@ -18,7 +22,11 @@
1822

1923
<ng-template #noInfo let-entry="entry">
2024
<ul class="list-unstyled mb-0">
21-
<li class="list-item text-truncate text-primary font-weight-bold">{{entry.value}}</li>
25+
<li class="list-item d-flex align-items-center">
26+
<img *ngIf="entry.source" class="mr-2" #imgTag [src]="getAuthoritySourceIcon(entry.source, imgTag)" [attr.alt]="('form.entry.source.' + entry.source) | translate" />
27+
<div class="text-truncate text-primary font-weight-bold">{{entry.value}}</div>
28+
<div *ngIf="entry.source" class="ml-2 text-truncate text-secondary">{{ ('form.entry.source.' + entry.source) | translate}}</div>
29+
</li>
2230
</ul>
2331
</ng-template>
2432

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@
5757
background-color: var(--bs-dropdown-link-hover-bg);
5858
}
5959
}
60+
61+
.list-item img {
62+
height: 20px
63+
}

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
} from '../../../../vocabulary-treeview-modal/vocabulary-treeview-modal.component';
4545
import { FormBuilderService } from '../../../form-builder.service';
4646
import { SubmissionService } from '../../../../../../submission/submission.service';
47+
import { environment } from '../../../../../../../environments/environment';
4748

4849
/**
4950
* Component representing a onebox input field.
@@ -77,6 +78,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
7778
preloadLevel: number;
7879
additionalInfoSelectIsOpen = false;
7980
alternativeNamesKey = 'alternative-names';
81+
authorithyIcons = environment.submission.icons.authority.sourceIcons;
8082

8183

8284
private isHierarchicalVocabulary$: Observable<boolean>;
@@ -413,4 +415,33 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
413415
type: 'vocabularyEntry'
414416
});
415417
}
418+
419+
420+
/**
421+
* Hide image on error
422+
* @param image
423+
*/
424+
handleImgError(image: HTMLElement): void {
425+
image.style.display = 'none';
426+
}
427+
428+
/**
429+
* Get configured icon for each authority source
430+
* @param source
431+
*/
432+
getAuthoritySourceIcon(source: string, image: HTMLElement): string {
433+
if (hasValue(this.authorithyIcons)) {
434+
const iconPath = this.authorithyIcons.find(icon => icon.source === source)?.path;
435+
436+
if (!hasValue(iconPath)) {
437+
this.handleImgError(image);
438+
}
439+
440+
return iconPath;
441+
} else {
442+
this.handleImgError(image);
443+
}
444+
445+
return '';
446+
}
416447
}

src/app/shared/form/builder/form-builder.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export class FormBuilderService extends DynamicFormService {
263263
(controlModel as any).metadataValue.place,
264264
(controlModel as any).metadataValue.confidence,
265265
(controlModel as any).metadataValue.otherInformation,
266+
(controlModel as any).metadataValue.source,
266267
(controlModel as any).metadataValue.metadata);
267268
}
268269

@@ -277,6 +278,7 @@ export class FormBuilderService extends DynamicFormService {
277278
(controlModel as any).value.place,
278279
(controlModel as any).value.confidence,
279280
(controlModel as any).value.otherInformation,
281+
(controlModel as any).value.source,
280282
(controlModel as any).value.metadata);
281283
}
282284
}

src/app/shared/form/builder/models/form-field-metadata-value.model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
2525
place: number;
2626
label: string;
2727
securityLevel: number;
28+
source: string;
2829
otherInformation: OtherInformation;
2930

3031
constructor(value: any = null,
@@ -35,7 +36,9 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
3536
place: number = 0,
3637
confidence: number = null,
3738
otherInformation: any = null,
38-
metadata: string = null) {
39+
source: string = null,
40+
metadata: string = null
41+
) {
3942
this.value = isNotNull(value) ? ((typeof value === 'string') ? value.trim() : value) : null;
4043
this.language = language;
4144
this.authority = authority;
@@ -54,7 +57,7 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
5457
if (isNotEmpty(metadata)) {
5558
this.metadata = metadata;
5659
}
57-
60+
this.source = source;
5861
this.otherInformation = otherInformation;
5962
}
6063

src/assets/i18n/en.json5

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,6 +2477,18 @@
24772477

24782478
"form.other-information.ror_orgunit_acronym": "ROR acronym",
24792479

2480+
"form.entry.source.local": "",
2481+
2482+
"form.entry.source.orcid": "",
2483+
2484+
"form.entry.source.ror": "",
2485+
2486+
"form.entry.source.openaire": "",
2487+
2488+
"form.entry.source.zdb": "",
2489+
2490+
"form.entry.source.sherpa": "- Sherpa Romeo",
2491+
24802492
"form.remove": "Remove",
24812493

24822494
"form.save": "Save",
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)