Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {HelperFunctions} from "../../utils/HelperFunctions.class";
3
import {Project} from "../../utils/result-preview/result-preview";
4
import {properties} from "../../../../environments/environment";
5

    
6
@Component({
7
  selector: 'fundedBy',
8
  template: `
9
    <div class="uk-text-muted">Funded by</div>
10
    <span *ngFor="let item of fundedByProjects.slice(0, showNum) let i=index">
11
          <a>             
12
            <span>
13
              <span
14
                  *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname'] ? item['funderShortname'] : item['funderName']}}</span>
15
              <span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
16
              <span
17
                  *ngIf="item['acronym'] || item['title']">| {{ item['acronym'] ? item['acronym'] : item['title']}}</span>
18
            </span>
19
          </a>
20
          <div class="default-dropdown uk-margin-remove-top uk-padding-small uk-dropdown"
21
               uk-dropdown="pos: bottom-left; mode:click">
22
            <span>Project</span>
23
            <div class="uk-margin-bottom">
24
              <a *ngIf="item.id" class="uk-h6 uk-margin-remove portal-link"
25
                 [queryParams]="{projectId: item.id}" [routerLink]="url">
26
                {{item['acronym'] ? item['acronym'] : item['title']}}
27
              </a>
28
              <span *ngIf="!item.id" class="uk-h6 uk-margin-remove">
29
                {{item['acronym'] ? item['acronym'] : item['title']}}
30
              </span>
31
              <div *ngIf="item.acronym && item.title">
32
                {{item.title}}
33
              </div>
34
            </div>
35
            <ul class="uk-list uk-padding-remove-left uk-margin-bottom">
36
              <li *ngIf="item.funderShortname || item.funderName">
37
                <span class="uk-text-muted">Funder: </span>
38
                {{item.funderName ? item.funderName : item.funderShortname}}
39
                <span *ngIf="item.funderShortname && item.funderName">
40
                  ({{item.funderShortname}})
41
                </span>
42
              </li>
43
              <li *ngIf="item.code">
44
                <span class="uk-text-muted">Project Code: </span>{{item.code}}
45
              </li>
46
              <li *ngIf="item.funding">
47
                <span class="uk-text-muted">Funding stream: </span>{{item.funding}}
48
              </li>
49
            </ul>
50
            <div *ngIf="item.provenanceAction || item.validated" class="uk-text-muted">
51
              <span *ngIf="item.validated">Validated by funder</span>
52
              <span *ngIf="item.provenanceAction && item.validated"> | </span>
53
              <span *ngIf="item.provenanceAction">{{item.provenanceAction}}</span>
54
            </div>
55
          </div>
56
          <span *ngIf="i < (fundedByProjects.slice(0, showNum).length - 1)">, </span>
57
        </span>
58
    <div *ngIf="showNum > threshold" class="uk-text-right uk-margin-bottom">
59
      <a (click)="showNum = threshold; scroll()">
60
        View less
61
      </a>
62
    </div>
63
    <div *ngIf="showNum == threshold && fundedByProjects && fundedByProjects.length > threshold"
64
         class="uk-text-right uk-margin-bottom">
65
      <a (click)="showNum = fundedByProjects.length;">
66
        View more
67
      </a>
68
    </div>
69
  `
70
})
71

    
72
export class FundedByComponent {
73
  @Input() fundedByProjects: Project[];
74
  
75
  public threshold: number = 5;
76
  public showNum: number = 5;
77
  public url = properties.searchLinkToProject.split('?')[0];
78
  
79
  public scroll() {
80
    HelperFunctions.scroll();
81
  }
82
}
(3-3/16)