Project

General

Profile

1
import {Component, Input} from '@angular/core';
2

    
3
@Component({
4
  selector: 'showSubjects',
5
  template: `
6
    <div *ngIf="classifiedSubjects && classifiedSubjects.size > 0" class="uk-text-small">
7
      <div class="uk-text-muted">
8
        Subjects
9
      </div>
10
      <div class="uk-margin-small-top">
11
        <div *ngFor="let key of getKeys(classifiedSubjects)" style="line-height: 20px">
12
          <span uk-icon="tag"></span>
13
          <span class="uk-text-bold uk-text-uppercase"> {{key}}: </span>
14
          <ng-container *ngFor="let subject of classifiedSubjects.get(key)">
15
            <span class="uk-display-inline-block label-classified">{{subject}}</span>
16
          </ng-container>
17
        </div>
18
      </div>
19
    </div>
20
    <div *ngIf="(subjects && subjects.length > 0) || (otherSubjects && otherSubjects.size > 0)" class="uk-text-small uk-margin-small-top"
21
      [class.uk-margin-top]="classifiedSubjects && classifiedSubjects.size > 0">
22
      <span *ngIf="subjects && subjects.length > 0">{{subjects.join(', ')}}</span>
23
      <span *ngIf="(subjects && subjects.length > 0) && (otherSubjects && otherSubjects.size > 0)">, </span>
24
      <span *ngIf="otherSubjects && otherSubjects.size > 0">
25
        <span *ngFor="let key of getKeys(otherSubjects); let i=index">
26
          <span *ngIf="otherSubjects.get(key).length > 0">
27
            <span>{{otherSubjects.get(key).join(', ')}}</span>
28
            <span *ngIf="i < (otherSubjects.size - 1)">, </span>
29
          </span>
30
        </span>
31
      </span>
32
    </div>
33
  `
34
})
35

    
36
export class ShowSubjectsComponent {
37
  @Input() subjects: string[];
38
  @Input() otherSubjects: Map<string, string[]>;
39
  @Input() classifiedSubjects: Map<string, string[]>;
40
  
41
  // private showClassifiedSbj: boolean = false;
42
  
43
  constructor() {
44
  }
45
  
46
  ngOnInit() {
47
  }
48
  
49
  public getKeys(map) {
50
    return Array.from(map.keys());
51
  }
52
}
(14-14/17)