aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/app/videos/video-list/video-sort.component.ts
blob: 2cb810ff567c005ef0efead6fb662b3633a5e669 (plain) (tree)
1
2
3
4
5
6
7
                                                                       
 
                                            


                            
                                                                       








                                           





                                         




                                         
                                         






                                       
import { Component, EventEmitter, Input, Output } from '@angular/core';

import { SortField } from '../shared/index';

@Component({
  selector: 'my-video-sort',
  templateUrl: 'client/app/videos/video-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) {
    return this.sortChoices[choiceKey];
  }

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