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="" loading="lazy">{{" "}}
23
              <img *ngIf="!author.orcid && author.orcid_pending" src="assets/common-assets/common/ORCIDiD_iconbw16x16.png" alt="" loading="lazy">{{" "}}
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
                <img *ngIf="author.orcid" src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="" loading="lazy">{{" "}}
38
                <img *ngIf="!author.orcid && author.orcid_pending" src="assets/common-assets/common/ORCIDiD_iconbw16x16.png" alt="" loading="lazy">{{" "}}
39

    
40
                <i *ngIf="author.orcid">Harvested from ORCID Public Data File</i>
41
                <i *ngIf="!author.orcid && author.orcid_pending">Derived by OpenAIRE algorithms or harvested from 3d party repositories</i>
42
              </div>
43
              
44
              <div>
45
                <div class="orcid uk-display-inline-block">
46
                  <input #element class="uk-padding-small uk-padding-remove-vertical uk-disabled"
47
                         style="min-height: 38px; min-width: 280px;" name="code" [value]="properties.orcidURL+(author.orcid ? author.orcid : author.orcid_pending)">
48
                  <button [class]="'uk-button uk-button-primary uk-button-small uk-icon copy orcid_clipboard_btn_auhtor_'+i" style="min-height: 40px"
49
                          (click)="copyToClipboard(element)" title="Copy to clipboard">
50
                   <span class="custom-icon custom-copy-white"></span>
51
                  </button>
52
                </div>
53
                <a class="uk-button uk-button-primary custom-icon-button target uk-button-icon uk-margin-small-left"
54
                   title="Visit author in ORCID" [href]="properties.orcidURL+(author.orcid ? author.orcid : author.orcid_pending)" target="_blank">
55
                  <span class="custom-icon custom-external-white"></span>
56
                </a>
57
              </div>
58
            </div>
59
          
60
            <hr>
61
            <div class="uk-margin-top">
62
              Search <b>{{author.fullName}}</b> in OpenAIRE
63
            </div>
64
            <div class="uk-text-center uk-margin-top uk-margin-large-left uk-margin-large-right">
65
              <a class="uk-button uk-text-bold portal-button uk-padding-remove-top uk-padding-remove-bottom uk-width-1-1"
66
                 (click)="onClick()"
67
                 [queryParams]="routerHelper.createQueryParams(['orcid','oc'],[(author['orcid'] ? author['orcid'] : author['orcid_pending']),'and'])"
68
                 routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults">
69
                <span class="space">Search</span>
70
              </a>
71
            </div>
72
        </div>
73
        </span>
74
      <span *ngIf="numberOfAuthors == authorsLimit && authors.length > authorsLimit">	... </span>
75
    </div>
76
    <div *ngIf="authors && showAll && numberOfAuthors == authorsLimit && authors.length > authorsLimit"
77
         class="uk-width-1-1 uk-text-right">
78
      <a (click)="numberOfAuthors = authors.length;">
79
        View all {{authors.length | number}} authors
80
      </a>
81
    </div>
82
    <div *ngIf="authors && showAll && numberOfAuthors > authorsLimit" class="uk-width-1-1 uk-text-right">
83
      <a (click)="numberOfAuthors = authorsLimit;">View less authors</a>
84
    </div>
85
  `
86
  
87
})
88

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