From a404e42b2b2878922322947101de1b072f8884fc Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 3 Nov 2021 21:01:58 +0100 Subject: [PATCH] feat: use task parsing to search for teams --- .../quick-actions/quick-actions.vue | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/components/quick-actions/quick-actions.vue b/src/components/quick-actions/quick-actions.vue index 93388d86b..6f6209bd0 100644 --- a/src/components/quick-actions/quick-actions.vue +++ b/src/components/quick-actions/quick-actions.vue @@ -62,7 +62,9 @@ import TeamModel from '@/models/team' import {CURRENT_LIST, LOADING, LOADING_MODULE, QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types' import ListModel from '@/models/list' import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue' -import {getHistory} from '../../modules/listHistory' +import {getHistory} from '@/modules/listHistory' +import {parseTaskText} from '@/modules/parseTaskText' +import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode' const TYPE_LIST = 'list' const TYPE_TASK = 'task' @@ -236,6 +238,9 @@ export default { return cmds }, + parsedQuery() { + return parseTaskText(this.query, getQuickAddMagicMode()) + }, searchMode() { if (this.query === '') { return SEARCH_MODE_ALL @@ -247,7 +252,7 @@ export default { if (this.query.startsWith('*')) { return SEARCH_MODE_LISTS } - if (this.query.startsWith('@')) { + if (assignees.length > 0 && list === '' && text === '' && labels.length === 0) { return SEARCH_MODE_TEAMS } @@ -301,12 +306,7 @@ export default { return } - let query = this.query - if (this.searchMode === SEARCH_MODE_TEAMS) { - query = query.substr(1) - } - - if (query === '' || this.selectedCmd !== null) { + if (this.query === '' || this.selectedCmd !== null) { return } @@ -315,12 +315,19 @@ export default { this.teamSearchTimeout = null } + const {assignees} = this.parsedQuery + this.teamSearchTimeout = setTimeout(async () => { - const r = await this.teamService.getAll({}, {s: query}) - this.foundTeams = r.map(t => { - t.title = t.name - return t - }) + const foundTeams = await Promise.all(assignees.map(t => { + return this.teamService.getAll({}, {s: t}) + .then(r => { + return r.map(t => { + t.title = t.name + return t + }) + }) + })) + this.foundTeams = foundTeams.flat() }, 150) }, closeQuickActions() { @@ -348,7 +355,7 @@ export default { this.doAction(this.results[0].type, this.results[0].items[0]) return } - + if (this.selectedCmd === null) { return }