Project

General

Profile

1
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 *ngIf="!item['inline']">
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
      <mark *ngIf="item['inline']">
16
        <span>{{item['labelContext']}}</span>
17
        <span *ngIf="item['labelCategory']"><span
18
            uk-icon="icon: arrow-right"></span>{{item['labelCategory']}}</span>
19
        <span *ngIf="item['labelConcept']">: {{item['labelConcept']}}</span>
20
      </mark>
21
    </div>
22
    <div *ngIf="showNum > threshold" class="uk-text-right">
23
      <a (click)="showNum = threshold; scroll()">
24
        View less
25
      </a>
26
    </div>
27
    <div *ngIf="showNum == threshold && contexts && contexts.length > threshold" class="uk-text-right">
28
      <a (click)="showNum = contexts.length;">
29
        View more
30
      </a>
31
    </div>
32
  `
33
})
34

    
35
export class RelatedToComponent {
36
  @Input() contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean }[];
37
  
38
  public threshold: number = 5;
39
  public showNum: number = 5;
40
  
41
  constructor() {
42
  }
43
  
44
  ngOnInit() {
45
  }
46
  
47
  public scroll() {
48
    HelperFunctions.scroll();
49
  }
50
}
(9-9/17)