Project

General

Profile

1
import {Component, Inject, Input, PLATFORM_ID} from '@angular/core';
2
import {ActivatedRoute} from "@angular/router";
3
import {HelperFunctions} from '../HelperFunctions.class';
4
import {RouterHelper} from "../routerHelper.class";
5
import {EnvProperties} from '../properties/env-properties';
6
import {isPlatformBrowser} from "@angular/common";
7
import {Author} from "../result-preview/result-preview";
8
import {AlertModal} from "../modal/alert";
9
import {properties} from "../../../../environments/environment";
10

    
11
@Component({
12
  selector: 'showAuthors',
13
  template: `
14
    <div *ngIf="authors" class="uk-height-max-medium uk-overflow-auto">
15
      <span *ngFor="let author of authors.slice(0,numberOfAuthors) let i=index">
16
          <span *ngIf="(!author.orcid && !author.orcid_pending) || !testBrowser"
17
                [class.uk-text-small]="small">
18
            {{author.fullName + "; "}}
19
          </span>
20
          <a *ngIf="(author.orcid || author.orcid_pending) && testBrowser" class="uk-display-inline-block space">
21
            <span>
22
              <img *ngIf="author.orcid" src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="">{{" "}}
23
              <img *ngIf="!author.orcid && author.orcid_pending" src="assets/common-assets/common/ORCIDiD_iconbw16x16.png" alt="">{{" "}}
24
              <span [class.uk-text-small]="small">
25
                {{author.fullName + "; "}}
26
              </span>
27
            </span>
28
          </a>
29
        <div *ngIf="(author.orcid || author.orcid_pending) && testBrowser"
30
             class="default-dropdown uk-margin-remove-top uk-padding-medium uk-dropdown"
31
             uk-dropdown="pos: bottom-left; mode:click" style="min-width: 465px !important;">
32
            <b class="uk-margin-top">{{author.fullName}}</b>
33
            <div>
34
              <div class="uk-text-muted uk-margin-small-bottom uk-margin-small-top">ORCID</div>
35
              
36
              <div class="uk-text-muted uk-text-small uk-margin-small-top uk-margin-small-bottom">
37
                <i *ngIf="author.orcid">Harvested from ORCID Public Data File</i>
38
                <i *ngIf="!author.orcid && author.orcid_pending">Derived by OpenAIRE algorithms or harvested from 3d party repositories</i>
39
              </div>
40
              
41
              <div>
42
                <div class="orcid uk-display-inline-block">
43
                  <input #element class="uk-padding-small uk-padding-remove-vertical uk-disabled"
44
                         style="min-height: 38px; min-width: 280px;" name="code" [value]="properties.orcidURL+(author.orcid ? author.orcid : author.orcid_pending)">
45
                  <button [class]="'uk-button uk-button-primary uk-button-small uk-icon copy orcid_clipboard_btn_auhtor_'+i" style="min-height: 40px"
46
                          (click)="copyToClipboard(element)" title="Copy to clipboard">
47
                   <span class="custom-icon custom-copy-white"></span>
48
                  </button>
49
                </div>
50
                <a class="uk-button uk-button-primary custom-icon-button target uk-button-icon uk-margin-small-left"
51
                   title="Visit author in ORCID" [href]="properties.orcidURL+(author.orcid ? author.orcid : author.orcid_pending)" target="_blank">
52
                  <span class="custom-icon custom-external-white"></span>
53
                </a>
54
              </div>
55
            </div>
56
          
57
            <hr>
58
            <div class="uk-margin-top">
59
              Search <b>{{author.fullName}}</b> in OpenAIRE
60
            </div>
61
            <div class="uk-text-center uk-margin-top uk-margin-large-left uk-margin-large-right">
62
              <a class="uk-button uk-text-bold portal-button uk-padding-remove-top uk-padding-remove-bottom uk-width-1-1"
63
                 (click)="onClick()"
64
                 [queryParams]="routerHelper.createQueryParams(['orcid','oc'],[(author['orcid'] ? author['orcid'] : author['orcid_pending']),'and'])"
65
                 routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults">
66
                <span class="space">Search</span>
67
              </a>
68
            </div>
69
        </div>
70
        </span>
71
      <span *ngIf="numberOfAuthors == authorsLimit && authors.length > authorsLimit">	... </span>
72
    </div>
73
    <div *ngIf="authors && showAll && numberOfAuthors == authorsLimit && authors.length > authorsLimit"
74
         class="uk-width-1-1 uk-text-right">
75
      <a (click)="numberOfAuthors = authors.length;">
76
        View all {{authors.length | number}} authors
77
      </a>
78
    </div>
79
    <div *ngIf="authors && showAll && numberOfAuthors > authorsLimit" class="uk-width-1-1 uk-text-right">
80
      <a (click)="numberOfAuthors = authorsLimit;">View less authors</a>
81
    </div>
82
  `
83
  
84
})
85

    
86
export class ShowAuthorsComponent {
87
  @Input() authors: Author[];
88
  @Input() authorsLimit: number = 30;
89
  @Input() showAll: boolean = true;
90
  @Input() small: boolean = true;
91
  @Input() modal: AlertModal;
92
  
93
  public numberOfAuthors: number;
94
  public properties: EnvProperties = properties;
95
  public routerHelper: RouterHelper = new RouterHelper();
96
  
97
  testBrowser: boolean;
98
  
99
  constructor(private route: ActivatedRoute, @Inject(PLATFORM_ID) private platformId: string) {
100
    this.testBrowser = isPlatformBrowser(platformId);
101
  }
102
  
103
  ngOnInit() {
104
    this.numberOfAuthors = this.authorsLimit;
105
  }
106
  
107
  copyToClipboard(element: HTMLInputElement) {
108
    element.select();
109
    if (typeof document !== 'undefined') {
110
      document.execCommand('copy');
111
    }
112
  }
113
  
114
  public scroll() {
115
    HelperFunctions.scroll();
116
  }
117
  
118
  public onClick() {
119
    if (this.modal) {
120
      this.modal.cancel();
121
    }
122
  }
123
}
(1-1/2)