diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-23 09:30:18 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-23 09:38:38 +0200 |
commit | 471bc22f19767c1cb1e7ba7ad0ddf0ff5f0e88f4 (patch) | |
tree | 606ccf517d76baf08539be7501d07dfd065884a9 /client/angular/app/search.component.ts | |
parent | 322940742b4dca168de6dfed0d1ebf5926dab528 (diff) | |
download | PeerTube-471bc22f19767c1cb1e7ba7ad0ddf0ff5f0e88f4.tar.gz PeerTube-471bc22f19767c1cb1e7ba7ad0ddf0ff5f0e88f4.tar.zst PeerTube-471bc22f19767c1cb1e7ba7ad0ddf0ff5f0e88f4.zip |
Add search with field choose support in client
Diffstat (limited to 'client/angular/app/search.component.ts')
-rw-r--r-- | client/angular/app/search.component.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/client/angular/app/search.component.ts b/client/angular/app/search.component.ts new file mode 100644 index 000000000..3e8db70c0 --- /dev/null +++ b/client/angular/app/search.component.ts | |||
@@ -0,0 +1,48 @@ | |||
1 | import { Component, EventEmitter, Output } from '@angular/core'; | ||
2 | import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from '@angular/router-deprecated'; | ||
3 | import { HTTP_PROVIDERS } from '@angular/http'; | ||
4 | |||
5 | import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown'; | ||
6 | |||
7 | import { Search, SearchField } from './search'; | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-search', | ||
11 | templateUrl: 'app/angular/app/search.component.html', | ||
12 | directives: [ DROPDOWN_DIRECTIVES ] | ||
13 | }) | ||
14 | |||
15 | export class SearchComponent { | ||
16 | @Output() search: EventEmitter<Search> = new EventEmitter<Search>(); | ||
17 | |||
18 | searchCriterias: Search = { | ||
19 | field: "name", | ||
20 | value: "" | ||
21 | } | ||
22 | fieldChoices = { | ||
23 | name: "Name", | ||
24 | author: "Author", | ||
25 | podUrl: "Pod Url", | ||
26 | magnetUri: "Magnet Uri" | ||
27 | } | ||
28 | |||
29 | get choiceKeys() { | ||
30 | return Object.keys(this.fieldChoices); | ||
31 | } | ||
32 | |||
33 | getStringChoice(choiceKey: SearchField): string { | ||
34 | return this.fieldChoices[choiceKey]; | ||
35 | } | ||
36 | |||
37 | choose($event:MouseEvent, choice: SearchField){ | ||
38 | $event.preventDefault(); | ||
39 | $event.stopPropagation(); | ||
40 | |||
41 | this.searchCriterias.field = choice; | ||
42 | } | ||
43 | |||
44 | doSearch(): void { | ||
45 | this.search.emit(this.searchCriterias); | ||
46 | } | ||
47 | |||
48 | } | ||