fix(quick add magic): use the project user service to find assignees for quick add magic

This commit is contained in:
kolaente 2023-04-03 19:34:05 +02:00 committed by konrad
parent 0724776ccb
commit 02c24a4814

View File

@ -29,6 +29,7 @@ import {useProjectStore} from '@/stores/projects'
import {useAttachmentStore} from '@/stores/attachments' import {useAttachmentStore} from '@/stores/attachments'
import {useKanbanStore} from '@/stores/kanban' import {useKanbanStore} from '@/stores/kanban'
import {useBaseStore} from '@/stores/base' import {useBaseStore} from '@/stores/base'
import ProjectUserService from '@/services/projectUsers'
// IDEA: maybe use a small fuzzy search here to prevent errors // IDEA: maybe use a small fuzzy search here to prevent errors
function findPropertyByValue(object, key, value) { function findPropertyByValue(object, key, value) {
@ -63,14 +64,14 @@ async function addLabelToTask(task: ITask, label: ILabel) {
return response return response
} }
async function findAssignees(parsedTaskAssignees: string[]): Promise<IUser[]> { async function findAssignees(parsedTaskAssignees: string[], projectId: number): Promise<IUser[]> {
if (parsedTaskAssignees.length <= 0) { if (parsedTaskAssignees.length <= 0) {
return [] return []
} }
const userService = new UserService() const userService = new ProjectUserService()
const assignees = parsedTaskAssignees.map(async a => { const assignees = parsedTaskAssignees.map(async a => {
const users = await userService.getAll({}, {s: a}) const users = await userService.getAll({projectId}, {s: a})
return validateUser(users, a) return validateUser(users, a)
}) })
@ -389,7 +390,7 @@ export const useTaskStore = defineStore('task', () => {
throw new Error('NO_PROJECT') throw new Error('NO_PROJECT')
} }
const assignees = await findAssignees(parsedTask.assignees) const assignees = await findAssignees(parsedTask.assignees, foundProjectId)
// Only clean up those assignees from the task title which actually exist // Only clean up those assignees from the task title which actually exist
let cleanedTitle = parsedTask.text let cleanedTitle = parsedTask.text