2021-04-13 16:25:51 +02:00
|
|
|
import {
|
2022-04-12 14:05:53 +02:00
|
|
|
AfterViewInit,
|
|
|
|
ChangeDetectorRef,
|
2021-04-13 16:25:51 +02:00
|
|
|
Component,
|
|
|
|
ElementRef,
|
|
|
|
HostListener,
|
|
|
|
Input,
|
2022-04-16 09:47:30 +02:00
|
|
|
QueryList, ViewChild,
|
2022-04-12 14:05:53 +02:00
|
|
|
ViewChildren
|
2021-04-13 16:25:51 +02:00
|
|
|
} from '@angular/core';
|
2020-03-17 18:48:02 +01:00
|
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
2021-02-10 10:33:36 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-03-16 14:09:46 +01:00
|
|
|
selector: 'showIdentifiers',
|
|
|
|
template: `
|
2022-03-15 12:13:28 +01:00
|
|
|
<!-- <div class="uk-text-muted">Persistent Identifiers</div> -->
|
2022-04-16 09:47:30 +02:00
|
|
|
<ng-template #identifiers_template let-modal="modal">
|
2021-04-13 14:33:40 +02:00
|
|
|
<ng-container *ngFor="let key of keys let i=index">
|
2022-04-16 09:47:30 +02:00
|
|
|
<!-- <div [class.uk-margin-bottom]="modal" [class.multi-line-ellipsis]="!modal" [class.lines-2]="keys.length === 1" [class.line-1]="keys.length > 1">-->
|
|
|
|
<div class="uk-flex-inline uk-flex-wrap uk-margin-medium-right"
|
|
|
|
[class.multi-line-ellipsis]="!modal" [class.lines-2]="keys.length === 1" [class.line-1]="keys.length > 1"
|
|
|
|
[class.uk-margin-bottom]="modal">
|
|
|
|
<p class="uk-margin-remove">
|
|
|
|
<span #content [id]="key" [class.uk-flex]="modal">
|
|
|
|
<span class="uk-text-meta uk-text-uppercase">{{key}}: </span>
|
|
|
|
<span [class.uk-margin-small-left]="modal">
|
|
|
|
<ng-container *ngFor="let item of identifiers.get(key) let j=index">
|
|
|
|
<a *ngIf="key == 'doi' || key == 'pmc' || key == 'pmid' || key == 'handle'"
|
|
|
|
[href]="getUrl(key) + item" target="_blank" class="uk-display-inline-block custom-external">
|
|
|
|
{{item}}
|
|
|
|
</a>
|
|
|
|
<ng-container *ngIf="(j !== (identifiers.get(key).length - 1))">, </ng-container>
|
|
|
|
</ng-container>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<!-- </div>-->
|
2020-03-16 14:09:46 +01:00
|
|
|
</ng-container>
|
2022-04-16 09:47:30 +02:00
|
|
|
</ng-template>
|
|
|
|
|
|
|
|
<div class="uk-height-max-medium uk-overflow-auto uk-text-small">
|
|
|
|
<ng-container *ngTemplateOutlet="identifiers_template; context: { modal: false}"></ng-container>
|
2021-04-13 14:33:40 +02:00
|
|
|
</div>
|
|
|
|
<div *ngIf="isLarge && showViewAll" class="uk-text-right uk-margin-small-top">
|
2022-04-16 09:47:30 +02:00
|
|
|
<a (click)="openIdentifiersModal()">View all</a>
|
2021-04-13 14:33:40 +02:00
|
|
|
</div>
|
2022-04-16 09:47:30 +02:00
|
|
|
|
|
|
|
<modal-alert #identifiersModal [classTitle]="'landing-modal-header'"
|
|
|
|
[classBody]="'landing-modal uk-padding-remove'">
|
|
|
|
<div class="uk-padding uk-padding-remove-top uk-text-small">
|
|
|
|
<ng-container *ngTemplateOutlet="identifiers_template; context: { modal: true}"></ng-container>
|
|
|
|
</div>
|
|
|
|
</modal-alert>
|
2020-03-16 14:09:46 +01:00
|
|
|
`
|
|
|
|
})
|
2021-04-13 16:25:51 +02:00
|
|
|
export class ShowIdentifiersComponent implements AfterViewInit {
|
2020-03-16 14:09:46 +01:00
|
|
|
@Input() identifiers: Map<string, string[]>;
|
2021-04-13 14:33:40 +02:00
|
|
|
@Input() showViewAll: boolean = false;
|
|
|
|
large: Map<string, boolean> = new Map<string, boolean>();
|
|
|
|
properties: EnvProperties = properties;
|
2021-04-13 16:25:51 +02:00
|
|
|
@ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>;
|
2022-04-16 09:47:30 +02:00
|
|
|
@ViewChild('identifiersModal') identifiersModal;
|
|
|
|
|
2021-04-16 13:45:42 +02:00
|
|
|
constructor(private cdr: ChangeDetectorRef) {
|
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(event) {
|
|
|
|
this.checkLarge();
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
ngAfterViewInit() {
|
|
|
|
this.checkLarge();
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
checkLarge() {
|
|
|
|
let overflow = (this.keys.length === 1?42:21);
|
|
|
|
if(typeof document !== "undefined") {
|
|
|
|
this.keys.forEach(key => {
|
2021-04-13 16:25:51 +02:00
|
|
|
let type = this.types.find(type => type.nativeElement.id === key);
|
2021-04-16 13:45:42 +02:00
|
|
|
this.large.set(key, type && type.nativeElement.offsetHeight > overflow);
|
2021-04-13 14:33:40 +02:00
|
|
|
});
|
2021-04-16 13:45:42 +02:00
|
|
|
this.cdr.detectChanges();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
get isLarge() {
|
|
|
|
for(let key of this.keys) {
|
|
|
|
if (this.large.get(key)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-13 14:33:40 +02:00
|
|
|
public get keys(): string[] {
|
|
|
|
return Array.from(this.identifiers.keys()).sort((a: string, b: string) => {
|
|
|
|
if (a === 'doi') {
|
2020-03-16 14:09:46 +01:00
|
|
|
return -1;
|
2021-04-13 14:33:40 +02:00
|
|
|
} else if (b === 'doi') {
|
2020-03-16 14:09:46 +01:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-04-16 09:47:30 +02:00
|
|
|
|
|
|
|
public getUrl(key: string): string {
|
|
|
|
if(key == "doi") {
|
|
|
|
return properties.doiURL;
|
|
|
|
} else if(key == "pmc") {
|
|
|
|
return properties.pmcURL;
|
|
|
|
} else if(key == "pmid") {
|
|
|
|
return properties.pmidURL;
|
|
|
|
} else if(key == "handle") {
|
|
|
|
return properties.handleURL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public openIdentifiersModal() {
|
|
|
|
this.identifiersModal.cancelButton = false;
|
|
|
|
this.identifiersModal.okButton = false;
|
|
|
|
this.identifiersModal.alertTitle = "Persistent Identifiers";
|
|
|
|
this.identifiersModal.open();
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|