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: `
|
2023-02-20 16:56:02 +01:00
|
|
|
<div *ngIf="!isMobile" class="uk-margin-small-bottom uk-flex uk-flex-between">
|
2022-04-12 14:15:04 +02:00
|
|
|
<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>
|
2023-01-13 14:57:26 +01:00
|
|
|
<span *ngIf="!viewAll || lessBtn" class="uk-text-emphasis uk-text-bolder">{{title}}</span>
|
2023-02-20 16:56:02 +01:00
|
|
|
<a *ngIf="viewAll && lessBtn" (click)="viewAll = !viewAll; lessBtn=false;"
|
2023-02-21 02:01:21 +01:00
|
|
|
class="view-more-less-link uk-link-text">View less</a>
|
2022-04-12 14:15:04 +02:00
|
|
|
<a *ngIf="fundedByProjects && fundedByProjects.length > threshold && !viewAll"
|
2023-02-21 02:01:21 +01:00
|
|
|
(click)="viewAllClick();" class="view-more-less-link uk-link-text">View all</a>
|
2022-04-12 14:15:04 +02:00
|
|
|
</div>
|
2023-02-20 16:56:02 +01:00
|
|
|
<div *ngIf="!isMobile">
|
2022-04-12 14:15:04 +02:00
|
|
|
<span *ngFor="let item of fundedByProjects.slice(0, viewAll?fundedByProjects.length:threshold) let i=index">
|
2023-02-20 16:56:02 +01:00
|
|
|
<span class="uk-text-emphasis">
|
|
|
|
<a class="uk-link uk-link-text">
|
|
|
|
<ng-container *ngTemplateOutlet="funder; context: {item: item}"></ng-container>
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<div class="default-dropdown uk-margin-remove-top uk-dropdown"
|
|
|
|
uk-dropdown="pos: bottom-left; mode:click">
|
|
|
|
<ng-container *ngTemplateOutlet="dropInfo; context: { item: item}"></ng-container>
|
|
|
|
</div>
|
|
|
|
<span *ngIf="i < (fundedByProjects.slice(0, viewAll?fundedByProjects.length:threshold).length - 1)">, </span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div *ngIf="isMobile">
|
|
|
|
<div *ngFor="let item of fundedByProjects.slice(0, viewAll?fundedByProjects.length:threshold) let i=index"
|
|
|
|
class="uk-flex uk-flex-between uk-flex-middle uk-margin-small-bottom">
|
|
|
|
<span class="uk-text-emphasis">
|
|
|
|
<ng-container *ngTemplateOutlet="funder; context: {item: item}"></ng-container>
|
|
|
|
</span>
|
|
|
|
<icon name="info" visuallyHidden="info" [type]="'outlined'" class="uk-link"></icon>
|
|
|
|
<div class="default-dropdown uk-margin-remove-top uk-dropdown"
|
|
|
|
uk-dropdown="pos: bottom-left; mode:click">
|
|
|
|
<ng-container *ngTemplateOutlet="dropInfo; context: { item: item}"></ng-container>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ng-template #funder let-item=item>
|
|
|
|
<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>
|
|
|
|
</ng-template>
|
|
|
|
|
|
|
|
<ng-template #dropInfo let-item=item>
|
|
|
|
<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">
|
2022-04-12 14:15:04 +02:00
|
|
|
{{item['acronym'] ? item['acronym'] : item['title']}}
|
|
|
|
</span>
|
2023-02-20 16:56:02 +01:00
|
|
|
<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">
|
2022-04-12 14:15:04 +02:00
|
|
|
({{item.funderShortname}})
|
|
|
|
</span>
|
2023-02-20 16:56:02 +01:00
|
|
|
</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>
|
|
|
|
<div *ngIf="getVocabularyLabel(item, provenanceActionVocabulary, i) || item.validated" class="uk-text-meta">
|
|
|
|
<span *ngIf="item.validated">Validated by funder</span>
|
|
|
|
<span *ngIf="item.provenanceAction && item.validated"> | </span>
|
|
|
|
<span *ngIf="item.provenanceAction">{{item.provenanceAction}}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
2020-05-20 22:34:29 +02:00
|
|
|
`
|
|
|
|
})
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
export class FundedByComponent {
|
2023-02-20 16:56:02 +01:00
|
|
|
@Input() isMobile: boolean = false;
|
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
|
|
|
}
|