import {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
authorsLimit" class="uk-text-meta">
+{{authors.length-authorsLimit | number}} more
authorsLimit && !viewAll">
+{{authors.length-authorsLimit | number}} Authors
`
})
export class ShowAuthorsComponent {
@Input() authors: Author[];
@Input() isSticky: boolean = false;
@Input() authorsLimit: number = 7;
@Input() showAll: boolean = true;
@Input() modal: AlertModal;
@Input() viewAll: boolean = false;
public lessBtn: boolean = false;
@ViewChild('authorsModal') authorsModal;
public properties: EnvProperties = properties;
public routerHelper: RouterHelper = new RouterHelper();
testBrowser: boolean;
public clipboard;
constructor(private route: ActivatedRoute, @Inject(PLATFORM_ID) private platformId: string) {
this.testBrowser = isPlatformBrowser(platformId);
}
ngOnInit() {}
public onClick() {
if (this.modal) {
this.modal.cancel();
}
}
public viewAllClick() {
if(this.authors.length <= this.authorsLimit*2) {
this.viewAll = true;
this.lessBtn = true;
} else {
this.openAuthorsModal();
}
}
public openAuthorsModal() {
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');
}
}
}