|
|
|
@ -62,7 +62,10 @@ 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, PrefixMode} from '@/modules/parseTaskText'
|
|
|
|
|
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
|
|
|
|
|
import {PREFIXES} from '@/modules/parseTaskText'
|
|
|
|
|
|
|
|
|
|
const TYPE_LIST = 'list'
|
|
|
|
|
const TYPE_TASK = 'task'
|
|
|
|
@ -107,11 +110,6 @@ export default {
|
|
|
|
|
results() {
|
|
|
|
|
let lists = []
|
|
|
|
|
if (this.searchMode === SEARCH_MODE_ALL || this.searchMode === SEARCH_MODE_LISTS) {
|
|
|
|
|
let query = this.query
|
|
|
|
|
if (this.searchMode === SEARCH_MODE_LISTS) {
|
|
|
|
|
query = query.substr(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ncache = {}
|
|
|
|
|
|
|
|
|
|
const history = getHistory()
|
|
|
|
@ -122,7 +120,9 @@ export default {
|
|
|
|
|
}),
|
|
|
|
|
...Object.values(this.$store.state.lists)])]
|
|
|
|
|
|
|
|
|
|
lists = (allLists.filter(l => {
|
|
|
|
|
const {list} = this.parsedQuery
|
|
|
|
|
|
|
|
|
|
lists = list === null ? [] : (allLists.filter(l => {
|
|
|
|
|
if (typeof l === 'undefined' || l === null) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
@ -139,7 +139,7 @@ export default {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return l.title.toLowerCase().includes(query.toLowerCase())
|
|
|
|
|
return l.title.toLowerCase().includes(list.toLowerCase())
|
|
|
|
|
}) ?? [])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -207,7 +207,9 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.$t('quickActions.hint')
|
|
|
|
|
const prefixes = PREFIXES[getQuickAddMagicMode()] ?? PREFIXES[PrefixMode.Default]
|
|
|
|
|
|
|
|
|
|
return this.$t('quickActions.hint', prefixes)
|
|
|
|
|
},
|
|
|
|
|
currentList() {
|
|
|
|
|
return Object.keys(this.$store.state[CURRENT_LIST]).length === 0 ? null : this.$store.state[CURRENT_LIST]
|
|
|
|
@ -236,18 +238,23 @@ export default {
|
|
|
|
|
|
|
|
|
|
return cmds
|
|
|
|
|
},
|
|
|
|
|
parsedQuery() {
|
|
|
|
|
return parseTaskText(this.query, getQuickAddMagicMode())
|
|
|
|
|
},
|
|
|
|
|
searchMode() {
|
|
|
|
|
if (this.query === '') {
|
|
|
|
|
return SEARCH_MODE_ALL
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.query.startsWith('#')) {
|
|
|
|
|
const {text, list, labels, assignees} = this.parsedQuery
|
|
|
|
|
|
|
|
|
|
if (assignees.length === 0 && text !== '') {
|
|
|
|
|
return SEARCH_MODE_TASKS
|
|
|
|
|
}
|
|
|
|
|
if (this.query.startsWith('*')) {
|
|
|
|
|
if (assignees.length === 0 && list !== null && text === '' && labels.length === 0) {
|
|
|
|
|
return SEARCH_MODE_LISTS
|
|
|
|
|
}
|
|
|
|
|
if (this.query.startsWith('@')) {
|
|
|
|
|
if (assignees.length > 0 && list === null && text === '' && labels.length === 0) {
|
|
|
|
|
return SEARCH_MODE_TEAMS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -268,12 +275,7 @@ export default {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let query = this.query
|
|
|
|
|
if (this.searchMode === SEARCH_MODE_TASKS) {
|
|
|
|
|
query = query.substr(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (query === '' || this.selectedCmd !== null) {
|
|
|
|
|
if (this.selectedCmd !== null) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -282,8 +284,35 @@ export default {
|
|
|
|
|
this.taskSearchTimeout = null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {text, list, labels} = this.parsedQuery
|
|
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
s: text,
|
|
|
|
|
filter_by: [],
|
|
|
|
|
filter_value: [],
|
|
|
|
|
filter_comparator: [],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (list !== null) {
|
|
|
|
|
const l = this.$store.getters['lists/findListByExactname'](list)
|
|
|
|
|
if (l !== null) {
|
|
|
|
|
params.filter_by.push('list_id')
|
|
|
|
|
params.filter_value.push(l.id)
|
|
|
|
|
params.filter_comparator.push('equals')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (labels.length > 0) {
|
|
|
|
|
const labelIds = this.$store.getters['labels/getLabelsByExactTitles'](labels).map(l => l.id)
|
|
|
|
|
if (labelIds.length > 0) {
|
|
|
|
|
params.filter_by.push('labels')
|
|
|
|
|
params.filter_value.push(labelIds.join())
|
|
|
|
|
params.filter_comparator.push('in')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.taskSearchTimeout = setTimeout(async () => {
|
|
|
|
|
const r = await this.taskService.getAll({}, {s: query})
|
|
|
|
|
const r = await this.taskService.getAll({}, params)
|
|
|
|
|
this.foundTasks = r.map(t => {
|
|
|
|
|
t.type = TYPE_TASK
|
|
|
|
|
const list = this.$store.getters['lists/getListById'](t.listId)
|
|
|
|
@ -301,12 +330,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 +339,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 => {
|
|
|
|
|
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() {
|
|
|
|
|