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

    
10
@Component({
11
  selector: 'showAuthors',
12
  template: `
13
    <div *ngIf="authors" class="uk-height-max-medium uk-overflow-auto">
14
      <span *ngFor="let author of authors.slice(0,numberOfAuthors) let i=index">
15
          <span *ngIf="!author.orcid || (properties.environment == 'production') || !testBrowser"
16
                [class.uk-text-small]="small">
17
            {{author.fullName + "; "}}
18
          </span>
19
          <a *ngIf="author.orcid && (properties.environment != 'production') && testBrowser">
20
            <img src="assets/common-assets/common/ORCIDiD_icon16x16.png" alt="">{{" "}}
21
            <span [class.uk-text-small]="small">
22
              {{author.fullName + "; "}}
23
            </span>
24
          </a>
25
        <div *ngIf="author.orcid && (properties.environment != 'production')"
26
             class="default-dropdown uk-margin-remove-top uk-padding-medium"
27
             uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;">
28
            <b class="uk-margin-top">{{author.fullName}}</b>
29
            <div>
30
              <div class="uk-text-muted uk-margin-small-bottom uk-margin-small-top">ORCID</div>
31
              <span><input #element class="uk-padding-small uk-disabled" name="code"
32
                           [value]="author.orcid"></span>{{" "}}
33
              <span>
34
                <button
35
                    [class]="'uk-icon-clipboard uk-button uk-button-primary uk-button-small orcid_clipboard_btn_auhtor_'+i"
36
                    (click)="copyToClipboard(element)" title="Copy to clipboard">
37
                  Copy
38
                </button>
39
                {{" "}}
40
                <a class="uk-button uk-button-primary uk-button-small" title="Visit author in Orcid"
41
                   [href]="properties.orcidURL+author.orcid" target="_blank">
42
                  Visit
43
                </a>
44
              </span>
45
            </div>
46

    
47
            <hr>
48
            <div class="uk-margin-top">
49
              Search <b>{{author.fullName}}</b> by <b>ORCID</b> in OpenAIRE's
50
            </div>
51
            <div class="uk-text-center uk-margin-small uk-margin-large-left uk-margin-large-right">
52
              <a class="uk-button uk-button-small portal-button uk-padding 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="/search/advanced/research-outcomes">
56
                  Research outcomes
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" class="uk-width-1-1 uk-text-right">
64
      <a (click)="numberOfAuthors = authors.length;">
65
        View all {{authors.length | number}} authors
66
      </a>
67
    </div>
68
    <div *ngIf="authors && showAll && numberOfAuthors > authorsLimit" class="uk-width-1-1 uk-text-right">
69
      <a (click)="numberOfAuthors = authorsLimit;">View less authors</a>
70
    </div>
71
  `
72
  
73
})
74

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