import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Project} from "../../utils/result-preview/result-preview"; import {properties} from "../../../../environments/environment"; import {HelperFunctions} from '../../utils/HelperFunctions.class'; import {RouterHelper} from "../../utils/routerHelper.class"; @Component({ selector: 'fundedBy', template: `
{{title}} {{title}} View less View all
,
{{item['funderShortname'] ? item['funderShortname'] : item['funderName']}} [no funder available] | {{ item['acronym'] ? item['acronym'] : item['title']}}
Project
{{item['acronym'] ? item['acronym'] : item['title']}} {{item['acronym'] ? item['acronym'] : item['title']}}
{{item.title}}
Validated by funder | {{item.provenanceAction}}
` }) export class FundedByComponent { @Input() isMobile: boolean = false; @Input() prevPath: string = ""; @Input() fundedByProjects: Project[]; @Input() viewAll: boolean = false; @Output() viewAllClicked = new EventEmitter(); public lessBtn: boolean = false; public threshold: number = 4; public url = properties.searchLinkToProject.split('?')[0]; public title: string = "Funded by"; @Input() provenanceActionVocabulary = null; // public provenancesCalculated: boolean[] = []; public routerHelper:RouterHelper = new RouterHelper(); public dropClicked: boolean = false; public ngOnInit() { this.fundedByProjects.forEach((project, index) => { this.getVocabularyLabel(project, this.provenanceActionVocabulary, index); }) } public viewAllClick() { if(this.fundedByProjects.length <= this.threshold*2) { this.viewAll = true; this.lessBtn = true; } else { this.viewAll = true; this.viewAllClicked.emit('fundedBy'); } } public viewLessClick() { this.viewAll = false; this.viewAllClicked.emit(""); } public getVocabularyLabel(item: any, vocabulary: any, index: number) { // if(!this.provenancesCalculated[index]) { // this.provenancesCalculated[index] = true; item.provenanceAction = HelperFunctions.getVocabularyLabel(item.provenanceAction, vocabulary, false); // } // return item.provenanceAction; } public addEoscPrevInParams(obj) { if(properties.adminToolsPortalType == "eosc" && this.prevPath) { let splitted: string[] = this.prevPath.split("?"); obj = this.routerHelper.addQueryParam("return_path", splitted[0], obj); if(splitted.length > 0) { obj = this.routerHelper.addQueryParam("search_params", splitted[1], obj); } } return obj; } }