PeerTube/client/angular/app/search.component.ts

47 lines
1014 B
TypeScript
Raw Normal View History

import { Component, EventEmitter, Output } from '@angular/core';
import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
import { Search, SearchField } from './search';
@Component({
selector: 'my-search',
templateUrl: 'app/angular/app/search.component.html',
directives: [ DROPDOWN_DIRECTIVES ]
})
export class SearchComponent {
@Output() search: EventEmitter<Search> = new EventEmitter<Search>();
searchCriterias: Search = {
2016-05-23 10:15:03 +00:00
field: 'name',
value: ''
};
fieldChoices = {
2016-05-23 10:15:03 +00:00
name: 'Name',
author: 'Author',
podUrl: 'Pod Url',
magnetUri: 'Magnet Uri'
};
get choiceKeys() {
return Object.keys(this.fieldChoices);
}
getStringChoice(choiceKey: SearchField): string {
return this.fieldChoices[choiceKey];
}
2016-05-23 10:15:03 +00:00
choose($event:MouseEvent, choice: SearchField) {
$event.preventDefault();
$event.stopPropagation();
this.searchCriterias.field = choice;
}
doSearch(): void {
this.search.emit(this.searchCriterias);
}
}