File tree Expand file tree Collapse file tree
app/shared/form/builder/ds-dynamic-form-ui/models/onebox Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88< ng-template #hasInfo let-entry ="entry ">
99 < ul class ="list-unstyled mb-0 ">
1010 < li class ="list-item d-flex align-items-center ">
11- < div *ngIf ="entry.source " class ="mr-2 ">
12- < img onerror ="handleImgError(this) " [src] ="'assets/images/' + entry.source + '.logo.icon.svg' " [attr.alt] ="('form.entry.source.' + entry.source) | translate " />
13- </ div >
11+ < img *ngIf ="entry.source " class ="mr-2 " #imgTag [src] ="getAuthoritySourceIcon(entry.source, imgTag) " [attr.alt] ="('form.entry.source.' + entry.source) | translate " />
1412 < div class ="text-truncate text-primary font-weight-bold "> {{entry.value}}</ div >
1513 < div *ngIf ="entry.source " class ="ml-2 text-truncate text-secondary "> {{ ('form.entry.source.' + entry.source) | translate}}</ div >
1614 </ li >
2523< ng-template #noInfo let-entry ="entry ">
2624 < ul class ="list-unstyled mb-0 ">
2725 < li class ="list-item d-flex align-items-center ">
28- < div *ngIf ="entry.source " class ="mr-2 ">
29- < img onerror ="handleImgError(this) " [src] ="'assets/images/' + entry.source + '.logo.icon.svg' " [attr.alt] ="('form.entry.source.' + entry.source) | translate " />
30- </ div >
26+ < img *ngIf ="entry.source " class ="mr-2 " #imgTag [src] ="getAuthoritySourceIcon(entry.source, imgTag) " [attr.alt] ="('form.entry.source.' + entry.source) | translate " />
3127 < div class ="text-truncate text-primary font-weight-bold "> {{entry.value}}</ div >
3228 < div *ngIf ="entry.source " class ="ml-2 text-truncate text-secondary "> {{ ('form.entry.source.' + entry.source) | translate}}</ div >
3329 </ li >
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import {
4444} from '../../../../vocabulary-treeview-modal/vocabulary-treeview-modal.component' ;
4545import { FormBuilderService } from '../../../form-builder.service' ;
4646import { 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 > ;
@@ -422,4 +424,24 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
422424 handleImgError ( image : HTMLElement ) : void {
423425 image . style . display = 'none' ;
424426 }
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+ }
425447}
Original file line number Diff line number Diff line change @@ -250,6 +250,32 @@ export class DefaultAppConfig implements AppConfig {
250250 style : 'text-muted'
251251 }
252252
253+ ] ,
254+ sourceIcons : [
255+ {
256+ source : 'orcid' ,
257+ path : 'assets/images/orcid.logo.icon.svg'
258+ } ,
259+ {
260+ source : 'openaire' ,
261+ path : 'assets/images/openaire.logo.icon.svg'
262+ } ,
263+ {
264+ source : 'ror' ,
265+ path : 'assets/images/ror.logo.icon.svg'
266+ } ,
267+ {
268+ source : 'sherpa' ,
269+ path : 'assets/images/sherpa.logo.icon.svg'
270+ } ,
271+ {
272+ source : 'zdb' ,
273+ path : 'assets/images/zdb.logo.icon.svg'
274+ } ,
275+ {
276+ source : 'local' ,
277+ path : 'assets/images/local.logo.icon.svg'
278+ } ,
253279 ]
254280 }
255281 } ,
Original file line number Diff line number Diff line change @@ -10,10 +10,16 @@ interface TypeBindConfig extends Config {
1010 field : string ;
1111}
1212
13+ interface AuthorithyIcon {
14+ source : string ,
15+ path : string
16+ }
17+
1318interface IconsConfig extends Config {
1419 metadata : MetadataIconConfig [ ] ;
1520 authority : {
1621 confidence : ConfidenceIconConfig [ ] ;
22+ sourceIcons ?: AuthorithyIcon [ ]
1723 } ;
1824}
1925
You can’t perform that action at this time.
0 commit comments