]>
Commit | Line | Data |
---|---|---|
df98563e | 1 | import { Component, EventEmitter, Input, Output } from '@angular/core' |
cf20596c | 2 | |
df98563e | 3 | import { SortField } from '../shared' |
cf20596c C |
4 | |
5 | @Component({ | |
6 | selector: 'my-video-sort', | |
ec8d8440 | 7 | templateUrl: './video-sort.component.html' |
cf20596c C |
8 | }) |
9 | ||
10 | export class VideoSortComponent { | |
df98563e | 11 | @Output() sort = new EventEmitter<any>() |
cf20596c | 12 | |
df98563e | 13 | @Input() currentSort: SortField |
cf20596c | 14 | |
a2457e9d | 15 | sortChoices: { [ P in SortField ]: string } = { |
cf20596c | 16 | 'name': 'Name - Asc', |
aff038cd C |
17 | '-name': 'Name - Desc', |
18 | 'duration': 'Duration - Asc', | |
19 | '-duration': 'Duration - Desc', | |
feb4bdfd | 20 | 'createdAt': 'Created Date - Asc', |
05a9feaa C |
21 | '-createdAt': 'Created Date - Desc', |
22 | 'views': 'Views - Asc', | |
86e83939 C |
23 | '-views': 'Views - Desc', |
24 | 'likes': 'Likes - Asc', | |
25 | '-likes': 'Likes - Desc' | |
df98563e | 26 | } |
cf20596c | 27 | |
df98563e C |
28 | get choiceKeys () { |
29 | return Object.keys(this.sortChoices) | |
cf20596c C |
30 | } |
31 | ||
df98563e C |
32 | getStringChoice (choiceKey: SortField) { |
33 | return this.sortChoices[choiceKey] | |
cf20596c C |
34 | } |
35 | ||
df98563e C |
36 | onSortChange () { |
37 | this.sort.emit(this.currentSort) | |
cf20596c C |
38 | } |
39 | } |