]>
Commit | Line | Data |
---|---|---|
cf20596c C |
1 | import { Component, Input, Output, EventEmitter } from '@angular/core'; |
2 | ||
3 | import { SortField } from './sort'; | |
4 | ||
5 | @Component({ | |
6 | selector: 'my-video-sort', | |
7 | // styleUrls: [ 'app/angular/videos/components/list/video-sort.component.css' ], | |
8 | templateUrl: 'app/angular/videos/components/list/video-sort.component.html' | |
9 | }) | |
10 | ||
11 | export class VideoSortComponent { | |
12 | @Output() sort = new EventEmitter<any>(); | |
13 | ||
14 | @Input() currentSort: SortField; | |
15 | ||
16 | sortChoices = { | |
17 | 'name': 'Name - Asc', | |
aff038cd C |
18 | '-name': 'Name - Desc', |
19 | 'duration': 'Duration - Asc', | |
20 | '-duration': 'Duration - Desc', | |
21 | 'createdDate': 'Created Date - Asc', | |
22 | '-createdDate': 'Created Date - Desc' | |
23 | }; | |
cf20596c C |
24 | |
25 | get choiceKeys() { | |
26 | return Object.keys(this.sortChoices); | |
27 | } | |
28 | ||
29 | getStringChoice(choiceKey: SortField): string { | |
30 | return this.sortChoices[choiceKey]; | |
31 | } | |
32 | ||
33 | onSortChange() { | |
34 | this.sort.emit(this.currentSort); | |
35 | } | |
36 | } |