aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos/components/list/video-sort.component.ts
blob: e63a70e9e064a8a8ac574e7482dd7bbfe0c7bb60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Component, Input, Output, EventEmitter } from '@angular/core';

import { SortField } from './sort';

@Component({
  selector: 'my-video-sort',
  // styleUrls: [ 'app/angular/videos/components/list/video-sort.component.css' ],
  templateUrl: 'app/angular/videos/components/list/video-sort.component.html'
})

export class VideoSortComponent {
  @Output() sort = new EventEmitter<any>();

  @Input() currentSort: SortField;

  sortChoices = {
    'name': 'Name - Asc',
    '-name': "Name - Desc",
    'duration': "Duration - Asc",
    '-duration': "Duration - Desc",
    'createdDate': "Created Date - Asc",
    '-createdDate': "Created Date - Desc"
  }

  get choiceKeys() {
    return Object.keys(this.sortChoices);
  }

  getStringChoice(choiceKey: SortField): string {
    return this.sortChoices[choiceKey];
  }

  onSortChange() {
    this.sort.emit(this.currentSort);
  }
}