import {
AfterContentInit,
AfterViewInit,
ChangeDetectorRef,
Component,
Inject,
Input,
PLATFORM_ID,
ViewChild
} from '@angular/core';
import {ActivatedRoute} from "@angular/router";
import {RouterHelper} from "../routerHelper.class";
import {EnvProperties} from '../properties/env-properties';
import {isPlatformBrowser} from "@angular/common";
import {Author} from "../result-preview/result-preview";
import {AlertModal} from "../modal/alert";
import {properties} from "../../../../environments/environment";
@Component({
selector: 'showAuthors',
template: `
{{author.fullName + ";"}}
{{author.fullName + ";"}}
{{author.fullName}}
ORCID
{{" "}}
{{" "}}
Harvested from ORCID Public Data File
Derived by OpenAIRE algorithms or harvested
from 3d party repositories
{{author.fullName}} in OpenAIRE
Authors:
authorsLimit" class="uk-text-meta">
+{{authors.length - authorsLimit | number}} more
authorsLimit && !viewAll">
authorsLimit" #authorsModal>
authorsLimit" #authorsModal classTitle="uk-tile-default uk-border-bottom">
`
})
export class ShowAuthorsComponent {
@Input() isMobile: boolean = false;
@Input() authors: Author[];
@Input() isSticky: boolean = false;
@Input() authorsLimit: number = 7;
@Input() showAll: boolean = true;
@Input() modal: AlertModal;
@Input() viewAll: boolean = false;
@Input() showInline: boolean = false; // do not open modal for "view more" when this is true
public lessBtn: boolean = false;
@ViewChild('authorsModal') authorsModal;
public properties: EnvProperties = properties;
public routerHelper: RouterHelper = new RouterHelper();
isBrowser: boolean;
public clipboard;
constructor(private route: ActivatedRoute, @Inject(PLATFORM_ID) private platformId: string) {
this.isBrowser = isPlatformBrowser(platformId);
}
ngOnInit() {}
ngOnDestroy() {
if(typeof document !== 'undefined') {
let modal_container = document.getElementById("modal-container");
modal_container.childNodes.forEach(c=> {
if (c['className'] && c['className'].includes("orcid-dropdown")) {
modal_container.removeChild(c);
}
});
}
}
public onClick() {
if (this.modal) {
this.modal.cancel();
}
if(this.authorsModal) {
this.authorsModal.cancel();
}
}
public viewAllClick() {
if(this.authors.length <= this.authorsLimit*2 || this.showInline) {
this.viewAll = true;
this.lessBtn = true;
} else {
this.openAuthorsModal();
}
}
public openAuthorsModal() {
if (this.isMobile) {
this.authorsModal.okButton = false;
this.authorsModal.title = "Authors";
this.authorsModal.open();
} else {
this.authorsModal.cancelButton = false;
this.authorsModal.okButton = false;
this.authorsModal.alertTitle = "Authors";
this.authorsModal.open();
}
}
copyToClipboard(element: HTMLInputElement) {
element.select();
if (typeof document !== 'undefined') {
document.execCommand('copy');
}
}
}