Project

General

Profile

1
import {Component, Input, ElementRef} from '@angular/core';
2

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

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

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

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

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

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

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

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

    
74
    constructor (private element: ElementRef) {}
75

    
76
    ngOnInit() {}
77

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

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

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

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

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

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

    
126
    public scroll() {
127
      console.info("scroll into view");
128
      if (typeof document !== 'undefined') {
129
         this.element.nativeElement.scrollIntoView();
130
      }
131
    }
132
}
(3-3/17)