Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {HelperFunctions} from "../../utils/HelperFunctions.class";
3

    
4
@Component({
5
    selector: 'fundedBy',
6
    template: `
7
      <dl class="uk-description-list-line">
8
        <dt   class="sideInfoTitle ">Funded by</dt>
9
        <dd class="line"
10
            *ngFor="let item of fundedByProjects.slice(0, showNum) let i=index">
11
          <div><!-- *ngIf="i<5 || showAll"-->
12
            <span   uk-tooltip="pos:right; delay:10"
13
                    title="{{buildFundingTooltip(item)}}">
14

    
15
              <a *ngIf="!item['inline'] && item.id"
16
                  [queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
17
                <span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
18
                <span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
19
                <span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
20
              </a>
21

    
22
              <a *ngIf="item['inline'] && item.id"
23
                  [queryParams]="{projectId: item.id}" routerLinkActive="router-link-active" routerLink="/search/project">
24
                <mark>
25
                  <span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
26
                  <span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
27
                  <span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
28
                </mark>
29
              </a>
30

    
31
              <span class="clickable" *ngIf="!item['inline'] && !item.id">
32
                <span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
33
                <span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
34
                <span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
35
              </span>
36

    
37
              <span class="clickable" *ngIf="item['inline'] && !item.id">
38
                <mark>
39
                  <span *ngIf="item['funderShortname'] || item['funderName']">{{item['funderShortname']?item['funderShortname']:item['funderName']}}</span>
40
                  <span *ngIf="!item['funderShortname'] && !item['funderName']">[no funder available]</span>
41
                  <span *ngIf="item['acronym'] || item['title']">| {{ item['acronym']?item['acronym']:item['title']}}</span>
42
                </mark>
43
              </span>
44

    
45
              <span class="uk-icon">
46
                <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>
47
              </span>
48
            </span>
49
          </div>
50
        </dd>
51
      </dl>
52
      <div *ngIf="showNum > threshold" class="uk-text-right">
53
        <a (click)="showNum = threshold; scroll()">
54
          View less
55
        </a>
56
      </div>
57
      <div *ngIf="showNum == threshold && fundedByProjects && fundedByProjects.length > 5">...</div>
58
      <div *ngIf="showNum == threshold && fundedByProjects && fundedByProjects.length > 5" class="uk-text-right">
59
        <a (click)="showNum = fundedByProjects.length;">
60
          View more
61
        </a>
62
      </div>
63
    `
64
    })
65

    
66
export class FundedByComponent {
67
    @Input() fundedByProjects: {  "id": string, "acronym": string, "title": string,
68
                                  "funderShortname": string, "funderName": string,
69
                                  "funding": string, "code": string, "provenanceAction": string,
70
                                  "inline": boolean }[];
71

    
72
    public threshold: number = 5;
73
    public showNum: number = 5;
74

    
75
    constructor () {}
76

    
77
    ngOnInit() {}
78

    
79
    public buildFundingTooltip(item: { "id": string, "acronym": string, "title": string,
80
                        "funderShortname": string, "funderName": string,
81
                        "funding": string, "code": string, "provenanceAction": string, inline: boolean}) {
82
      let tooltipContent: string = "<div class='tooltip-custom-font-size uk-padding-small'>";
83

    
84
      if(item.title) {
85
          tooltipContent += "<h5>"+item.title+"</h5>";
86
      }
87

    
88
      if(item.code || item.funderName || item.funderShortname || item.funding) {
89
        tooltipContent += "<p>";
90
      }
91

    
92
      if(item.code) {
93
          tooltipContent += "<div>Project Code: "+item.code+"</div>";
94
      }
95
      if(item.funderName || item.funderShortname) {
96
          tooltipContent += "<div>Funder: ";
97
          if(item.funderName && item.funderShortname) {
98
              tooltipContent += item.funderName + " ("+ item.funderShortname +")";
99
          } else if(item.funderName) {
100
              tooltipContent += item.funderName;
101
          } else {
102
              tooltipContent += item.funderShortname;
103
          }
104
          tooltipContent += "</div>";
105
      }
106

    
107
      if(item.funding) {
108
          tooltipContent += "<div>Funding: "+ item.funding + "</div>";
109
      }
110

    
111
      if(item.code || item.funderName || item.funderShortname || item.funding) {
112
        tooltipContent += "</p>";
113
      }
114
      tooltipContent += "<span class='uk-text-meta'>";
115
      if(item.provenanceAction == 'Repository') {
116
        tooltipContent += "Link provided by Repository";
117
      } else if(item.provenanceAction == 'OpenAIRE') {
118
        tooltipContent += "Link inferred by OpenAIRE";
119
      } else if(item.provenanceAction == 'USer') {
120
        tooltipContent += "Link claimed by User";
121
      }
122
      tooltipContent += "</span>";
123
      tooltipContent+="</div>"
124
      return tooltipContent;
125
    }
126

    
127
    public scroll() {
128
      HelperFunctions.scroll();
129
    }
130
}
(3-3/18)