Skip to content

Commit 4cc3f66

Browse files
[DSC-1708] orcid display refactor
1 parent acd0b9c commit 4cc3f66

3 files changed

Lines changed: 37 additions & 14 deletions

File tree

src/app/shared/metadata-link-view/metadata-link-view-orcid/metadata-link-view-orcid.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<span class="d-flex align-items-center txt-value">
2-
<a *ngIf="(orcidUrl$ | async); else noOrcidUrl" href="{{(orcidUrl$ | async)}}/{{metadataValue.value}}" target="_blank">
3-
{{ metadataValue.value }}
2+
<a *ngIf="(orcidUrl$ | async); else noOrcidUrl" href="{{(orcidUrl$ | async)}}/{{metadataValue}}" target="_blank">
3+
{{ metadataValue }}
44
</a>
55

6-
<ng-template #noOrcidUrl>{{ metadataValue.value }}</ng-template>
6+
<ng-template #noOrcidUrl>{{ metadataValue }}</ng-template>
77

88
<img *ngIf="hasOrcidBadge()"
99
placement="top"

src/app/shared/metadata-link-view/metadata-link-view-orcid/metadata-link-view-orcid.component.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ describe('MetadataLinkViewOrcidComponent', () => {
5252
}
5353
}), BrowserAnimationsModule],
5454
providers: [
55-
{ provide: 'fieldProvider', useValue: null },
56-
{ provide: 'itemProvider', useValue: testItem },
57-
{ provide: 'metadataValueProvider', useValue: metadataValue },
58-
{ provide: 'renderingSubTypeProvider', useValue: '' },
59-
{ provide: 'tabNameProvider', useValue: '' },
6055
{ provide: ConfigurationDataService, useValue: configurationDataService}
6156
],
6257
})
Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
1+
import { ConfigurationProperty } from './../../../core/shared/configuration-property.model';
2+
import { getFirstSucceededRemoteDataPayload } from './../../../core/shared/operators';
3+
import { ConfigurationDataService } from './../../../core/data/configuration-data.service';
14
import { Component, Input, OnInit } from '@angular/core';
25
import { Item } from '../../../core/shared/item.model';
3-
import { OrcidComponent } from '../../../cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/orcid/orcid.component';
6+
import { Observable, map } from 'rxjs';
47

58
@Component({
69
selector: 'ds-metadata-link-view-orcid',
710
templateUrl: './metadata-link-view-orcid.component.html',
8-
styleUrls: ['./metadata-link-view-orcid.component.scss']
11+
styleUrls: ['./metadata-link-view-orcid.component.scss'],
912
})
10-
export class MetadataLinkViewOrcidComponent extends OrcidComponent implements OnInit {
11-
13+
export class MetadataLinkViewOrcidComponent implements OnInit {
14+
/**
15+
* Item value to display the metadata for
16+
*/
1217
@Input() itemValue: Item;
1318

19+
metadataValue: string;
20+
21+
orcidUrl$: Observable<string>;
22+
23+
constructor(protected configurationService: ConfigurationDataService) {}
24+
1425
ngOnInit(): void {
15-
this.item = this.itemValue;
16-
super.ngOnInit();
26+
this.orcidUrl$ = this.configurationService
27+
.findByPropertyName('orcid.domain-url')
28+
.pipe(
29+
getFirstSucceededRemoteDataPayload(),
30+
map((property: ConfigurationProperty) =>
31+
property?.values?.length > 0 ? property.values[0] : null
32+
)
33+
);
34+
this.metadataValue = this.itemValue.firstMetadataValue(
35+
'person.identifier.orcid'
36+
);
37+
}
38+
39+
public hasOrcid(): boolean {
40+
return this.itemValue.hasMetadata('person.identifier.orcid');
41+
}
42+
43+
public hasOrcidBadge(): boolean {
44+
return this.itemValue.hasMetadata('dspace.orcid.authenticated');
1745
}
1846
}

0 commit comments

Comments
 (0)