feat: update autocomplete to filter tasks by users instead of assignees
This commit is contained in:
parent
805482d646
commit
66b8ee4f18
|
|
@ -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<FilterAutocompleteOptions>({
|
|||
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<FilterAutocompleteOptions>({
|
|||
|
||||
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<FilterAutocompleteOptions>({
|
|||
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<FilterAutocompleteOptions>({
|
|||
|
||||
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<FilterAutocompleteOptions>({
|
|||
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
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
class="filter-autocomplete__label"
|
||||
/>
|
||||
<User
|
||||
v-else-if="item.fieldType === 'assignees'"
|
||||
v-else-if="item.fieldType === 'users'"
|
||||
:user="(item.item as unknown as IUser)"
|
||||
:avatar-size="20"
|
||||
class="filter-autocomplete__user"
|
||||
|
|
|
|||
Loading…
Reference in New Issue