diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-29 16:16:24 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-10 14:02:41 +0200 |
commit | 5fb2e2888ce032c638e4b75d07458642f0833e52 (patch) | |
tree | 8830d873569316889b8134027e9a43b198cca38f /client/src/app/header/suggestion.component.ts | |
parent | 62e7be634bc189f942ae51cb4b080079ab503ff0 (diff) | |
download | PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.gz PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.zst PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.zip |
First implem global search
Diffstat (limited to 'client/src/app/header/suggestion.component.ts')
-rw-r--r-- | client/src/app/header/suggestion.component.ts | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/client/src/app/header/suggestion.component.ts b/client/src/app/header/suggestion.component.ts index 69641b511..250a5411e 100644 --- a/client/src/app/header/suggestion.component.ts +++ b/client/src/app/header/suggestion.component.ts | |||
@@ -1,24 +1,24 @@ | |||
1 | import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy } from '@angular/core' | 1 | import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy, OnChanges } from '@angular/core' |
2 | import { RouterLink } from '@angular/router' | 2 | import { RouterLink } from '@angular/router' |
3 | import { ListKeyManagerOption } from '@angular/cdk/a11y' | 3 | import { ListKeyManagerOption } from '@angular/cdk/a11y' |
4 | 4 | ||
5 | export type Result = { | 5 | export type SuggestionPayload = { |
6 | text: string | 6 | text: string |
7 | type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any' | 7 | type: SuggestionPayloadType |
8 | routerLink?: RouterLink, | 8 | routerLink?: RouterLink |
9 | default?: boolean | 9 | default: boolean |
10 | } | 10 | } |
11 | 11 | ||
12 | export type SuggestionPayloadType = 'search-instance' | 'search-index' | ||
13 | |||
12 | @Component({ | 14 | @Component({ |
13 | selector: 'my-suggestion', | 15 | selector: 'my-suggestion', |
14 | templateUrl: './suggestion.component.html', | 16 | templateUrl: './suggestion.component.html', |
15 | styleUrls: [ './suggestion.component.scss' ], | 17 | styleUrls: [ './suggestion.component.scss' ] |
16 | changeDetection: ChangeDetectionStrategy.OnPush | ||
17 | }) | 18 | }) |
18 | export class SuggestionComponent implements OnInit, ListKeyManagerOption { | 19 | export class SuggestionComponent implements OnInit, ListKeyManagerOption { |
19 | @Input() result: Result | 20 | @Input() result: SuggestionPayload |
20 | @Input() highlight: string | 21 | @Input() highlight: string |
21 | @Output() selected = new EventEmitter() | ||
22 | 22 | ||
23 | disabled = false | 23 | disabled = false |
24 | active = false | 24 | active = false |
@@ -30,8 +30,4 @@ export class SuggestionComponent implements OnInit, ListKeyManagerOption { | |||
30 | ngOnInit () { | 30 | ngOnInit () { |
31 | if (this.result.default) this.active = true | 31 | if (this.result.default) this.active = true |
32 | } | 32 | } |
33 | |||
34 | selectItem () { | ||
35 | this.selected.emit(this.result) | ||
36 | } | ||
37 | } | 33 | } |