Project

General

Profile

1 61381 k.triantaf
import {Component, Input} from "@angular/core";
2
import {EnvProperties} from "../../../utils/properties/env-properties";
3
import {Author} from "../../../utils/result-preview/result-preview";
4
import {AlertModal} from "../../../utils/modal/alert";
5
6
@Component({
7
  selector: 'landing-header',
8
  template: `
9
    <div class="title-section uk-margin-bottom" [ngClass]="titleClass">
10
      <div>
11
        <span *ngIf="entityType" class="uk-text-capitalize">
12
          {{entityType}}
13
        </span>
14
        <span *ngIf="types && removeUnknown(types, true).length > 0">
15
           {{(entityType?' . ':'') + removeUnknown(types, true).join(' . ')}}
16
        </span>
17
        <span>
18
          <span *ngIf="startDate || endDate">
19
            {{' . '}}
20
          </span>
21
          <span *ngIf="startDate && !endDate">
22
            {{'from '}}
23
          </span>
24
          <span *ngIf="!startDate && endDate">
25
            {{'until '}}
26
          </span>
27
          <span *ngIf="startDate">
28
            {{startDate | date: 'yyyy'}}
29
          </span>
30
          <span *ngIf="startDate && endDate">
31
            {{' - '}}
32
          </span>
33
          <span *ngIf="endDate">
34
            {{endDate | date: 'yyyy'}}
35
          </span>
36
        </span>
37
        <span *ngIf="status && status != ''">
38
          {{' . ' + status}}
39
        </span>
40
        <span *ngIf="year && year != ''">
41
          {{' . ' + year}}
42
        </span>
43
        <span *ngIf="embargoEndDate">
44
         . Embargo end date: {{embargoEndDate | date: 'dd MMM yyyy'}}
45
        </span>
46
        <span *ngIf="underCuration">
47
          . <span title="{{buildCurationTooltip()}}"
48
                  uk-tooltip="pos:bottom-right; delay:10;"
49
                  class="under-curation">Under curation</span>
50
        </span>
51
      </div>
52
      <showTitle [titleName]="title" classNames="uk-margin-remove-bottom" [isH1]="isTitleH1"></showTitle>
53
      <div *ngIf="subTitle">
54
        <span class="uk-text-muted" [innerHTML]="subTitle"></span>
55
      </div>
56
      <div *ngIf="authors" class="uk-margin-top">
57
        <showAuthors [authorsLimit]="authorLimit" [modal]="modal" [showAll]="showAllAuthors" [authors]="authors" [small]="false"></showAuthors>
58
      </div>
59
    </div>`
60
})
61
export class LandingHeaderComponent {
62
  @Input() entityType: string;
63
  @Input() properties: EnvProperties;
64
  @Input() types: string[];
65
  @Input() startDate: number; // project landing
66
  @Input() endDate: number; // project landing
67
  @Input() status: string;  // project landing
68
  @Input() year: string;
69
  @Input() embargoEndDate: Date;
70
  @Input() title: string;
71
  @Input() subTitle: string;
72
  @Input() authors: Author[];
73
  @Input() authorLimit: number = 30;
74
  @Input() showAllAuthors: boolean = true;
75
  @Input() underCuration: boolean = false;
76
  @Input() modal: AlertModal;
77
  @Input() titleClass: string = null;
78
  @Input() isTitleH1:boolean =true;
79
  public removeUnknown(array: string[], type: boolean = false): string[] {
80
    if (type) {
81
      return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown');
82
    } else {
83
      return array.filter(value => value.toLowerCase() !== 'unknown');
84
    }
85
  }
86
87
  public removeDuplicates(array: string[]): string[] {
88
    return array.filter(value => value.toLowerCase() !== this.entityType);
89
  }
90
91
  public buildCurationTooltip(): string {
92
    let tooltipContent: string = "<div class='uk-padding-small'>";
93
94
    tooltipContent += "<h5>Record in preview</h5>";
95
    tooltipContent += "<p>Bibliographic record accepted by the system, but not yet processed by <br> OpenAIRE tools for information quality improvement and de-duplication</p>";
96
97
    tooltipContent += "</div>";
98
    return tooltipContent;
99
  }
100
}