Project

General

Profile

1 61381 k.triantaf
import {Component, Input} from '@angular/core';
2
import {HelperFunctions} from "../../utils/HelperFunctions.class";
3
4
@Component({
5
  selector: 'relatedTo',
6
  template: `
7
    <div class="uk-text-muted">Communities</div>
8
    <div class="uk-margin-small-left" *ngFor="let item of contexts.slice(0, showNum); let i=index">
9
        <span>
10
          <span>{{item['labelContext']}}</span>
11
          <span *ngIf="item['labelCategory']"><span
12
              uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
13
          <span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
14
        </span>
15
    </div>
16
    <div *ngIf="showNum > threshold" class="uk-text-right">
17
      <a (click)="showNum = threshold; scroll()">
18
        View less
19
      </a>
20
    </div>
21
    <div *ngIf="showNum == threshold && contexts && contexts.length > threshold" class="uk-text-right">
22
      <a (click)="showNum = contexts.length;">
23
        View more
24
      </a>
25
    </div>
26
  `
27
})
28
29
export class RelatedToComponent {
30
  @Input() contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string }[];
31
32
  public threshold: number = 5;
33
  public showNum: number = 5;
34
35
  constructor() {
36
  }
37
38
  ngOnInit() {
39
  }
40
41
  public scroll() {
42
    HelperFunctions.scroll();
43
  }
44
}