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';
@Component({
selector: 'fundedBy',
template: `
{{item['funderShortname'] ? item['funderShortname'] : item['funderName']}}
[no funder available]
| {{ item['acronym'] ? item['acronym'] : item['title']}}
Project
-
Funder:
{{item.funderName ? item.funderName : item.funderShortname}}
({{item.funderShortname}})
-
Project Code: {{item.code}}
-
Funding stream: {{item.funding}}
Validated by funder
|
{{item.provenanceAction}}
`
})
export class FundedByComponent {
@Input() isMobile: boolean = false;
@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 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;
}
}