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 || !testBrowser"
17
                [class.uk-text-small]="small">
18
            {{author.fullName + "; "}}
19
          </span>
20
          <a *ngIf="author.orcid && testBrowser">
21
            <img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="">{{" "}}
22
            <span [class.uk-text-small]="small">
23
              {{author.fullName + "; "}}
24
            </span>
25
          </a>
26
        <div *ngIf="author.orcid && testBrowser"
27
             class="default-dropdown uk-margin-remove-top uk-padding-medium uk-dropdown"
28
             uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;">
29
            <b class="uk-margin-top">{{author.fullName}}</b>
30
            <div>
31
              <div class="uk-text-muted uk-margin-small-bottom uk-margin-small-top">ORCID</div>
32
              <div>
33
                <div class="orcid uk-display-inline-block">
34
                  <input #element class="uk-padding-small uk-padding-remove-vertical uk-disabled" style="min-height: 38px" name="code" [value]="author.orcid">
35
                  <button [class]="'uk-button uk-button-primary uk-button-small uk-icon copy orcid_clipboard_btn_auhtor_'+i" style="min-height: 40px"
36
                          (click)="copyToClipboard(element)" title="Copy to clipboard">
37
                   <span class="custom-icon custom-copy-white"></span>
38
                  </button>
39
                </div>
40
                <a class="uk-button uk-button-primary custom-icon-button target uk-button-icon uk-margin-small-left"
41
                   title="Visit author in Orcid" [href]="properties.orcidURL+author.orcid" target="_blank">
42
                  <span class="custom-icon custom-external-white"></span>
43
                </a>
44
              </div>
45
            </div>
46

    
47
            <hr>
48
            <div class="uk-margin-top">
49
              Search <b>{{author.fullName}}</b> in OpenAIRE
50
            </div>
51
            <div class="uk-text-center uk-margin-top uk-margin-large-left uk-margin-large-right">
52
              <a class="uk-button uk-text-bold portal-button uk-padding-remove-top uk-padding-remove-bottom uk-width-1-1"
53
                 (click)="onClick()"
54
                 [queryParams]="routerHelper.createQueryParams(['orcid','oc'],[author['orcid'],'and'])"
55
                 routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults">
56
                <span class="space">Search</span>
57
              </a>
58
            </div>
59
        </div>
60
        </span>
61
      <span *ngIf="numberOfAuthors == authorsLimit && authors.length > authorsLimit">	... </span>
62
    </div>
63
    <div *ngIf="authors && showAll && numberOfAuthors == authorsLimit && authors.length > authorsLimit"
64
         class="uk-width-1-1 uk-text-right">
65
      <a (click)="numberOfAuthors = authors.length;">
66
        View all {{authors.length | number}} authors
67
      </a>
68
    </div>
69
    <div *ngIf="authors && showAll && numberOfAuthors > authorsLimit" class="uk-width-1-1 uk-text-right">
70
      <a (click)="numberOfAuthors = authorsLimit;">View less authors</a>
71
    </div>
72
  `
73
  
74
})
75

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