feat: use task parsing to search for teams
This commit is contained in:
parent
a47d106926
commit
a404e42b2b
|
@ -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
|
||||
}
|
||||
|
|
Reference in New Issue