Project

General

Profile

1
import {Component, Input, ElementRef} from '@angular/core';
2
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
3

    
4
@Component({
5
    selector: 'fundedBy',
6
    template: `
7
      <dl class="uk-description-list-line">
8
        <dt  class="title">Funded By</dt>
9
        <dd class="line"
10
            *ngFor="let item of fundedByProjects 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
        <dd *ngIf="showAll" class="uk-text-right">
52
          <a (click)="showAll = !showAll; scroll()">
53
            View less
54
          </a>
55
        </dd>
56
        <dd *ngIf="!showAll && fundedByProjects && fundedByProjects.length > 5">...</dd>
57
        <dd *ngIf="!showAll && fundedByProjects && fundedByProjects.length > 5" class="uk-text-right">
58
          <a (click)="showAll = !showAll;">
59
            View more
60
          </a>
61
        </dd>
62
      </dl>
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
    public showAll: boolean = false;
72

    
73
    constructor (private element: ElementRef) {}
74

    
75
    ngOnInit() {}
76

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

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

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

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

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

    
109
      if(item.code || item.funderName || item.funderShortname || item.funding) {
110
        tooltipContent += "</p>";
111
      }
112

    
113
      if(item.provenanceAction == 'Repository') {
114
        tooltipContent += "Provided by Repository";
115
      } else if(item.provenanceAction == 'OpenAIRE') {
116
        tooltipContent += "Inferred by OpenAIRE";
117
      } else if(item.provenanceAction == 'USer') {
118
        tooltipContent += "Claimed by User";
119
      }
120

    
121
      tooltipContent+="</div>"
122
      return tooltipContent;
123
    }
124

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