From 49a2cd4b216e7cb822c5a79a5c263c7c3a01c706 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Mon, 27 Dec 2021 21:13:32 +0100 Subject: [PATCH] Fix sort dialog namespace autocomplete TG-14 Signed-off-by: Trivernis --- .../sort-dialog/sort-dialog.component.html | 3 ++- .../file-search/sort-dialog/sort-dialog.component.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.html b/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.html index 9ac19a5..c6fc105 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.html +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.html @@ -23,7 +23,8 @@ Namespace Name diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.ts b/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.ts index 98a5a31..a45f665 100644 --- a/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.ts +++ b/mediarepo-ui/src/app/components/shared/sidebar/file-search/sort-dialog/sort-dialog.component.ts @@ -15,7 +15,6 @@ export class SortDialogComponent { public sortEntries: SortKey[] = [] public suggestedNamespaces: Namespace[] = []; - public namespaceFormControl = new FormControl(); private namespaces: Namespace[] = []; @@ -24,10 +23,6 @@ export class SortDialogComponent { this.sortEntries = data.sortEntries; tagService.namespaces.subscribe( namespaces => this.namespaces = namespaces); - this.namespaceFormControl.valueChanges.subscribe( - v => this.suggestedNamespaces = this.namespaces.sort( - (a, b) => this.compareSuggestionNamespaces(v, a.name, b.name)) - .slice(0, 50)) } addNewSortKey() { @@ -53,6 +48,12 @@ export class SortDialogComponent { event.currentIndex); } + public updateAutocompleteSuggestions(value: string): void { + this.suggestedNamespaces = this.namespaces.sort( + (a, b) => this.compareSuggestionNamespaces(value, a.name, b.name)) + .slice(0, 50) + } + private compareSuggestionNamespaces(query: string, l: string, r: string): number { if (l.startsWith(query) && !r.startsWith(query)) { return -1;