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 + ";"}} orcid orcid bw {{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: +{{authors.length - authorsLimit | number}} more +{{authors.length - authorsLimit | number}} Authors
View less
` }) 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() {} public onClick() { if (this.modal) { this.modal.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'); } } }