From 66b8ee4f186b9da2aee0c3326b7cd1f561345e50 Mon Sep 17 00:00:00 2001 From: benshi <807629978@qq.com> Date: Thu, 18 Jun 2026 02:41:40 +0000 Subject: [PATCH] feat: update autocomplete to filter tasks by users instead of assignees --- .../input/filter/FilterAutocomplete.ts | 30 +++++++++---------- .../input/filter/FilterCommandsList.vue | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/input/filter/FilterAutocomplete.ts b/frontend/src/components/input/filter/FilterAutocomplete.ts index b5e771b7e..6133b2f96 100644 --- a/frontend/src/components/input/filter/FilterAutocomplete.ts +++ b/frontend/src/components/input/filter/FilterAutocomplete.ts @@ -46,7 +46,7 @@ interface SuggestionItem { name?: string } -export type AutocompleteField = 'labels' | 'assignees' | 'projects' +export type AutocompleteField = 'labels' | 'users' | 'projects' /** * Calculates the replacement range for autocomplete selection. @@ -223,7 +223,7 @@ export default Extension.create({ return labelStore.filterLabelsByQuery([], autocompleteContext.search).filter((label): label is ILabel => label !== undefined) as SuggestionItem[] } - if (fieldType === 'assignees') { + if (fieldType === 'users') { if (debounceTimer) { clearTimeout(debounceTimer) @@ -231,23 +231,23 @@ export default Extension.create({ return new Promise((resolve) => { debounceTimer = setTimeout(async () => { - let assigneeSuggestions: SuggestionItem[] = [] + let userSuggestions: SuggestionItem[] = [] try { if (this.options.projectId) { // @ts-expect-error - projectId is used for URL replacement but not part of IAbstract - assigneeSuggestions = await projectUserService.getAll({projectId: this.options.projectId}, {s: autocompleteContext.search}) as SuggestionItem[] + userSuggestions = await projectUserService.getAll({projectId: this.options.projectId}, {s: autocompleteContext.search}) as SuggestionItem[] } else { - assigneeSuggestions = await userService.getAll({} as IUser, {s: autocompleteContext.search}) as SuggestionItem[] + userSuggestions = await userService.getAll({} as IUser, {s: autocompleteContext.search}) as SuggestionItem[] } - // For assignees, show suggestions even with empty search, but limit if we have many - if (autocompleteContext.search === '' && assigneeSuggestions.length > 10) { - assigneeSuggestions = assigneeSuggestions.slice(0, 10) + // Show suggestions even with empty search, but limit if we have many + if (autocompleteContext.search === '' && userSuggestions.length > 10) { + userSuggestions = userSuggestions.slice(0, 10) } } catch (error) { - console.error('Error fetching assignee suggestions:', error) - assigneeSuggestions = [] + console.error('Error fetching user suggestions:', error) + userSuggestions = [] } - resolve(assigneeSuggestions) + resolve(userSuggestions) }, 300) }) } @@ -340,7 +340,7 @@ export default Extension.create({ if (LABEL_FIELDS.includes(field)) { fieldType = 'labels' } else if (ASSIGNEE_FIELDS.includes(field) || CREATOR_FIELDS.includes(field)) { - fieldType = 'assignees' + fieldType = 'users' } else if (PROJECT_FIELDS.includes(field)) { fieldType = 'projects' } @@ -364,8 +364,8 @@ export default Extension.create({ const items = suggestions.map(item => ({ id: item.id, - title: fieldType === 'assignees' ? item.username : item.title, - description: fieldType === 'assignees' ? `${item.name || item.username}` : item.title, + title: fieldType === 'users' ? item.username : item.title, + description: fieldType === 'users' ? `${item.name || item.username}` : item.title, item, fieldType, context: autocompleteContext, @@ -389,7 +389,7 @@ export default Extension.create({ items, command: (item: AutocompleteItem) => { // Handle selection - const newValue = item.fieldType === 'assignees' + const newValue = item.fieldType === 'users' ? (item.item as IUser).username : (item.item as IProject | ILabel).title // Use currentAutocompleteContext (outer variable) for up-to-date positions diff --git a/frontend/src/components/input/filter/FilterCommandsList.vue b/frontend/src/components/input/filter/FilterCommandsList.vue index 34c92887b..7473f5467 100644 --- a/frontend/src/components/input/filter/FilterCommandsList.vue +++ b/frontend/src/components/input/filter/FilterCommandsList.vue @@ -15,7 +15,7 @@ class="filter-autocomplete__label" />