2022-04-12 14:15:04 +02:00
|
|
|
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
2020-03-17 14:55:34 +01:00
|
|
|
import {Project} from "../../utils/result-preview/result-preview";
|
2020-07-10 10:37:17 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2022-09-06 15:28:51 +02:00
|
|
|
import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
2018-05-16 17:42:42 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2020-05-20 22:34:29 +02:00
|
|
|
selector: 'fundedBy',
|
|
|
|
template: `
|
2022-04-12 14:15:04 +02:00
|
|
|
<div class="uk-margin-small-bottom uk-flex uk-flex-between">
|
|
|
|
<span *ngIf="viewAll && !lessBtn" class="clickable uk-h6 uk-flex uk-flex-middle" (click)="viewLessClick()">
|
|
|
|
<icon class="uk-margin-small-right" name="arrow_back" flex="true" ratio="1.2"></icon>
|
|
|
|
{{title}}
|
|
|
|
</span>
|
2022-04-16 09:47:30 +02:00
|
|
|
<span *ngIf="!viewAll || lessBtn" class="uk-text-light-grey">{{title}}</span>
|
2022-06-09 15:45:39 +02:00
|
|
|
<a *ngIf="viewAll && lessBtn" (click)="viewAll = !viewAll; lessBtn=false;" class="view-more-less-link">View less</a>
|
2022-04-12 14:15:04 +02:00
|
|
|
<a *ngIf="fundedByProjects && fundedByProjects.length > threshold && !viewAll"
|
2022-06-09 15:45:39 +02:00
|
|
|
(click)="viewAllClick();" class="view-more-less-link">View all</a>
|
2022-04-12 14:15:04 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<span *ngFor="let item of fundedByProjects.slice(0, viewAll?fundedByProjects.length:threshold) let i=index">
|
2022-04-16 09:47:30 +02:00
|
|
|
<span class="uk-text-emphasis">
|
2022-06-09 15:45:39 +02:00
|
|
|
<a class="uk-link uk-link-text">
|
2021-11-23 09:44:36 +01:00
|
|
|
<span
|
|
|
|
*ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname'] ? item['funderShortname'] : item['funderName']}}</span>
|
|
|
|
<span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
|
|
|
|
<span
|
|
|
|
*ngIf="item['acronym'] || item['title']">| {{ item['acronym'] ? item['acronym'] : item['title']}}</span>
|
2022-04-16 09:47:30 +02:00
|
|
|
</a>
|
|
|
|
</span>
|
2022-04-12 14:15:04 +02:00
|
|
|
<div class="default-dropdown uk-margin-remove-top uk-dropdown"
|
2021-11-23 09:44:36 +01:00
|
|
|
uk-dropdown="pos: bottom-left; mode:click">
|
2022-04-12 14:15:04 +02:00
|
|
|
<div class="uk-padding-small">
|
|
|
|
<span>Project</span>
|
|
|
|
<div class="uk-margin-bottom">
|
|
|
|
<a *ngIf="item.id" class="uk-h6 uk-margin-remove portal-link"
|
|
|
|
[queryParams]="{projectId: item.id}" [routerLink]="url">
|
|
|
|
{{item['acronym'] ? item['acronym'] : item['title']}}
|
|
|
|
</a>
|
|
|
|
<span *ngIf="!item.id" class="uk-h6 uk-margin-remove">
|
|
|
|
{{item['acronym'] ? item['acronym'] : item['title']}}
|
|
|
|
</span>
|
|
|
|
<div *ngIf="item.acronym && item.title" class="uk-text-meta">
|
|
|
|
{{item.title}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<ul class="uk-list uk-padding-remove-left uk-margin-bottom">
|
|
|
|
<li *ngIf="item.funderShortname || item.funderName">
|
|
|
|
<span class="uk-text-meta">Funder: </span>
|
|
|
|
{{item.funderName ? item.funderName : item.funderShortname}}
|
|
|
|
<span *ngIf="item.funderShortname && item.funderName">
|
|
|
|
({{item.funderShortname}})
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
<li *ngIf="item.code">
|
|
|
|
<span class="uk-text-meta">Project Code: </span>{{item.code}}
|
|
|
|
</li>
|
|
|
|
<li *ngIf="item.funding">
|
|
|
|
<span class="uk-text-meta">Funding stream: </span>{{item.funding}}
|
|
|
|
</li>
|
|
|
|
</ul>
|
2022-09-08 23:35:11 +02:00
|
|
|
<div *ngIf="getVocabularyLabel(item, provenanceActionVocabulary, i) || item.validated" class="uk-text-meta">
|
2022-04-12 14:15:04 +02:00
|
|
|
<span *ngIf="item.validated">Validated by funder</span>
|
|
|
|
<span *ngIf="item.provenanceAction && item.validated"> | </span>
|
2022-09-08 23:35:11 +02:00
|
|
|
<span *ngIf="item.provenanceAction">{{item.provenanceAction}}</span>
|
2022-04-12 14:15:04 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-23 09:44:36 +01:00
|
|
|
</div>
|
2022-04-12 14:15:04 +02:00
|
|
|
<span *ngIf="i < (fundedByProjects.slice(0, viewAll?fundedByProjects.length:threshold).length - 1)">, </span>
|
2021-11-23 09:44:36 +01:00
|
|
|
</span>
|
|
|
|
</div>
|
2020-05-20 22:34:29 +02:00
|
|
|
`
|
|
|
|
})
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
export class FundedByComponent {
|
2020-03-17 14:55:34 +01:00
|
|
|
@Input() fundedByProjects: Project[];
|
2022-04-12 14:15:04 +02:00
|
|
|
@Input() viewAll: boolean = false;
|
|
|
|
@Output() viewAllClicked = new EventEmitter();
|
|
|
|
public lessBtn: boolean = false;
|
|
|
|
public threshold: number = 4;
|
2020-07-10 10:37:17 +02:00
|
|
|
public url = properties.searchLinkToProject.split('?')[0];
|
2022-04-12 14:15:04 +02:00
|
|
|
public title: string = "Funded by";
|
2022-09-06 15:28:51 +02:00
|
|
|
@Input() provenanceActionVocabulary = null;
|
2022-09-08 23:35:11 +02:00
|
|
|
public provenancesCalculated: boolean[] = [];
|
2022-04-12 14:15:04 +02:00
|
|
|
|
|
|
|
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("");
|
2020-03-17 14:55:34 +01:00
|
|
|
}
|
2022-09-06 15:28:51 +02:00
|
|
|
|
2022-09-08 23:35:11 +02:00
|
|
|
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;
|
2022-09-06 15:28:51 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|