openaire-library/landingPages/landing-utils/fundedBy.component.ts

126 lines
6.1 KiB
TypeScript

import {Component, Input} from '@angular/core';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
@Component({
selector: 'fundedBy',
template: `
<dl [class]="'uk-description-list-line' + ((fundedByProjects && fundedByProjects.length > threshold) ? ' uk-margin-remove-bottom' : '')">
<dt class="sideInfoTitle ">Funded by</dt>
<dd class="line"
*ngFor="let item of fundedByProjects.slice(0, showNum) let i=index">
<div><!-- *ngIf="i<5 || showAll"-->
<span uk-tooltip="pos:right; delay:10"
title="{{buildFundingTooltip(item)}}">
<a *ngIf="!item['inline'] && item.id"
[queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
<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>
</a>
<a *ngIf="item['inline'] && item.id"
[queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
<mark>
<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>
</mark>
</a>
<span class="clickable" *ngIf="!item['inline'] && !item.id">
<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>
</span>
<span class="clickable" *ngIf="item['inline'] && !item.id">
<mark>
<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>
</mark>
</span>
{{" "}}<span class="uk-icon">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" icon="info" ratio="1"><path d="M12.13,11.59 C11.97,12.84 10.35,14.12 9.1,14.16 C6.17,14.2 9.89,9.46 8.74,8.37 C9.3,8.16 10.62,7.83 10.62,8.81 C10.62,9.63 10.12,10.55 9.88,11.32 C8.66,15.16 12.13,11.15 12.14,11.18 C12.16,11.21 12.16,11.35 12.13,11.59 C12.08,11.95 12.16,11.35 12.13,11.59 L12.13,11.59 Z M11.56,5.67 C11.56,6.67 9.36,7.15 9.36,6.03 C9.36,5 11.56,4.54 11.56,5.67 L11.56,5.67 Z"></path><circle fill="none" stroke="#000" stroke-width="1.1" cx="10" cy="10" r="9"></circle></svg>
</span>
</span>
</div>
</dd>
</dl>
<div *ngIf="showNum > threshold" class="uk-text-right uk-margin-bottom">
<a (click)="showNum = threshold; scroll()">
View less
</a>
</div>
<!-- <div *ngIf="showNum == threshold && fundedByProjects && fundedByProjects.length > 5">...</div>-->
<div *ngIf="showNum == threshold && fundedByProjects && fundedByProjects.length > threshold" class="uk-text-right uk-margin-bottom">
<a (click)="showNum = fundedByProjects.length;">
View more
</a>
</div>
`
})
export class FundedByComponent {
@Input() fundedByProjects: { "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "code": string, "provenanceAction": string,
"inline": boolean }[];
public threshold: number = 5;
public showNum: number = 5;
constructor () {}
ngOnInit() {}
public buildFundingTooltip(item: { "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string,
"funding": string, "code": string, "provenanceAction": string, inline: boolean}) {
let tooltipContent: string = "<div class='tooltip-custom-font-size uk-padding-small uk-light'>";
if(item.title) {
tooltipContent += "<p class='uk-h5'>"+item.title+"</p>";
}
if(item.code || item.funderName || item.funderShortname || item.funding) {
tooltipContent += "<p>";
}
if(item.code) {
tooltipContent += "<div>Project Code: "+item.code+"</div>";
}
if(item.funderName || item.funderShortname) {
tooltipContent += "<div>Funder: ";
if(item.funderName && item.funderShortname) {
tooltipContent += item.funderName + " ("+ item.funderShortname +")";
} else if(item.funderName) {
tooltipContent += item.funderName;
} else {
tooltipContent += item.funderShortname;
}
tooltipContent += "</div>";
}
if(item.funding) {
tooltipContent += "<div>Funding: "+ item.funding + "</div>";
}
if(item.code || item.funderName || item.funderShortname || item.funding) {
tooltipContent += "</p>";
}
tooltipContent += "<span class='uk-text-small'>";
tooltipContent += item.provenanceAction;
tooltipContent += "</span>";
tooltipContent+="</div>";
return tooltipContent;
}
public scroll() {
HelperFunctions.scroll();
}
}