feat(frontend): preload assignee list on click with current user first
Show all available project members in the assignee dropdown when the user clicks the search input, instead of requiring them to type first. The current user is sorted to the top of the list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
811e5efe20
commit
52bfdf0ad2
|
|
@ -7,11 +7,13 @@
|
|||
:placeholder="$t('task.assignee.placeholder')"
|
||||
:multiple="true"
|
||||
:search-results="foundUsers"
|
||||
:show-empty="true"
|
||||
label="name"
|
||||
:select-placeholder="$t('task.assignee.selectPlaceholder')"
|
||||
:autocomplete-enabled="false"
|
||||
@search="findUser"
|
||||
@select="addAssignee"
|
||||
@click="preloadUsers"
|
||||
>
|
||||
<template #items="{items}">
|
||||
<AssigneeList
|
||||
|
|
@ -41,6 +43,7 @@ import Multiselect from '@/components/input/Multiselect.vue'
|
|||
import {includesById} from '@/helpers/utils'
|
||||
import ProjectUserService from '@/services/projectUsers'
|
||||
import {success} from '@/message'
|
||||
import {useAuthStore} from '@/stores/auth'
|
||||
import {useTaskStore} from '@/stores/tasks'
|
||||
|
||||
import type {IUser} from '@/modelTypes/IUser'
|
||||
|
|
@ -60,6 +63,7 @@ const emit = defineEmits<{
|
|||
'update:modelValue': [value: IUser[] | undefined],
|
||||
}>()
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const taskStore = useTaskStore()
|
||||
const {t} = useI18n({useScope: 'global'})
|
||||
|
||||
|
|
@ -68,6 +72,14 @@ const foundUsers = ref<IUser[]>([])
|
|||
const assignees = ref<IUser[]>([])
|
||||
let isAdding = false
|
||||
|
||||
let hasPreloaded = false
|
||||
|
||||
function preloadUsers() {
|
||||
if (hasPreloaded) return
|
||||
hasPreloaded = true
|
||||
findUser('')
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
|
|
@ -109,6 +121,8 @@ async function removeAssignee(user: IUser) {
|
|||
async function findUser(query: string) {
|
||||
const response = await projectUserService.getAll({projectId: props.projectId}, {s: query}) as IUser[]
|
||||
|
||||
const currentUserId = authStore.info?.id
|
||||
|
||||
// Filter the results to not include users who are already assigned
|
||||
foundUsers.value = response
|
||||
.filter(({id}) => !includesById(assignees.value, id))
|
||||
|
|
@ -117,6 +131,11 @@ async function findUser(query: string) {
|
|||
u.name = getDisplayName(u)
|
||||
return u
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (a.id === currentUserId) return -1
|
||||
if (b.id === currentUserId) return 1
|
||||
return 0
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue