Add filters for quick action bar
This commit is contained in:
parent
7802cf619f
commit
0f42ed3cf7
1 changed files with 80 additions and 8 deletions
|
@ -20,7 +20,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="has-text-grey-light p-4" v-if="hintText !== ''">
|
<div class="help has-text-grey-light p-2" v-if="hintText !== ''">
|
||||||
{{ hintText }}
|
{{ hintText }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -72,6 +72,11 @@ const CMD_NEW_LIST = 'newList'
|
||||||
const CMD_NEW_NAMESPACE = 'newNamespace'
|
const CMD_NEW_NAMESPACE = 'newNamespace'
|
||||||
const CMD_NEW_TEAM = 'newTeam'
|
const CMD_NEW_TEAM = 'newTeam'
|
||||||
|
|
||||||
|
const SEARCH_MODE_ALL = 'all'
|
||||||
|
const SEARCH_MODE_TASKS = 'tasks'
|
||||||
|
const SEARCH_MODE_LISTS = 'lists'
|
||||||
|
const SEARCH_MODE_TEAMS = 'teams'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'quick-actions',
|
name: 'quick-actions',
|
||||||
data() {
|
data() {
|
||||||
|
@ -84,6 +89,7 @@ export default {
|
||||||
taskService: null,
|
taskService: null,
|
||||||
|
|
||||||
foundTeams: [],
|
foundTeams: [],
|
||||||
|
teamSearchTimeout: null,
|
||||||
teamService: null,
|
teamService: null,
|
||||||
|
|
||||||
namespaceService: null,
|
namespaceService: null,
|
||||||
|
@ -99,9 +105,17 @@ export default {
|
||||||
return active
|
return active
|
||||||
},
|
},
|
||||||
results() {
|
results() {
|
||||||
const lists = (Object.values(this.$store.state.lists).filter(l => {
|
let lists = []
|
||||||
return l.title.toLowerCase().includes(this.query.toLowerCase())
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
lists = (Object.values(this.$store.state.lists).filter(l => {
|
||||||
|
return l.title.toLowerCase().includes(query.toLowerCase())
|
||||||
|
}) ?? [])
|
||||||
|
}
|
||||||
|
|
||||||
const cmds = this.availableCmds
|
const cmds = this.availableCmds
|
||||||
.filter(a => a.title.toLowerCase().includes(this.query.toLowerCase()))
|
.filter(a => a.title.toLowerCase().includes(this.query.toLowerCase()))
|
||||||
|
@ -167,7 +181,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ''
|
return 'You can use # to only seach for tasks, * to only search for lists and @ to only search for teams.'
|
||||||
},
|
},
|
||||||
currentList() {
|
currentList() {
|
||||||
return Object.keys(this.$store.state[CURRENT_LIST]).length === 0 ? null : this.$store.state[CURRENT_LIST]
|
return Object.keys(this.$store.state[CURRENT_LIST]).length === 0 ? null : this.$store.state[CURRENT_LIST]
|
||||||
|
@ -196,6 +210,23 @@ export default {
|
||||||
|
|
||||||
return cmds
|
return cmds
|
||||||
},
|
},
|
||||||
|
searchMode() {
|
||||||
|
if (this.query === '') {
|
||||||
|
return SEARCH_MODE_ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.query.startsWith('#')) {
|
||||||
|
return SEARCH_MODE_TASKS
|
||||||
|
}
|
||||||
|
if (this.query.startsWith('*')) {
|
||||||
|
return SEARCH_MODE_LISTS
|
||||||
|
}
|
||||||
|
if (this.query.startsWith('@')) {
|
||||||
|
return SEARCH_MODE_TEAMS
|
||||||
|
}
|
||||||
|
|
||||||
|
return SEARCH_MODE_ALL
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.taskService = new TaskService()
|
this.taskService = new TaskService()
|
||||||
|
@ -206,9 +237,20 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
search() {
|
search() {
|
||||||
this.searchTasks()
|
this.searchTasks()
|
||||||
|
this.searchTeams()
|
||||||
},
|
},
|
||||||
searchTasks() {
|
searchTasks() {
|
||||||
if (this.query === '' || this.selectedCmd !== null) {
|
if (this.searchMode !== SEARCH_MODE_ALL && this.searchMode !== SEARCH_MODE_TASKS) {
|
||||||
|
this.foundTasks = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let query = this.query
|
||||||
|
if (this.searchMode === SEARCH_MODE_TASKS) {
|
||||||
|
query = query.substr(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query === '' || this.selectedCmd !== null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +260,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.taskSearchTimeout = setTimeout(() => {
|
this.taskSearchTimeout = setTimeout(() => {
|
||||||
this.taskService.getAll({}, {s: this.query})
|
this.taskService.getAll({}, {s: query})
|
||||||
.then(r => {
|
.then(r => {
|
||||||
r = r.map(t => {
|
r = r.map(t => {
|
||||||
t.type = TYPE_TASK
|
t.type = TYPE_TASK
|
||||||
|
@ -233,6 +275,37 @@ export default {
|
||||||
})
|
})
|
||||||
}, 150)
|
}, 150)
|
||||||
},
|
},
|
||||||
|
searchTeams() {
|
||||||
|
if (this.searchMode !== SEARCH_MODE_ALL && this.searchMode !== SEARCH_MODE_TEAMS) {
|
||||||
|
this.foundTeams = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let query = this.query
|
||||||
|
if (this.searchMode === SEARCH_MODE_TEAMS) {
|
||||||
|
query = query.substr(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query === '' || this.selectedCmd !== null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.teamSearchTimeout !== null) {
|
||||||
|
clearTimeout(this.teamSearchTimeout)
|
||||||
|
this.teamSearchTimeout = null
|
||||||
|
}
|
||||||
|
|
||||||
|
this.teamSearchTimeout = setTimeout(() => {
|
||||||
|
this.teamService.getAll({}, {s: query})
|
||||||
|
.then(r => {
|
||||||
|
r = r.map(t => {
|
||||||
|
t.title = t.name
|
||||||
|
return t
|
||||||
|
})
|
||||||
|
this.$set(this, 'foundTeams', r)
|
||||||
|
})
|
||||||
|
}, 150)
|
||||||
|
},
|
||||||
closeQuickActions() {
|
closeQuickActions() {
|
||||||
this.$store.commit(QUICK_ACTIONS_ACTIVE, false)
|
this.$store.commit(QUICK_ACTIONS_ACTIVE, false)
|
||||||
},
|
},
|
||||||
|
@ -321,7 +394,6 @@ export default {
|
||||||
.then(r => {
|
.then(r => {
|
||||||
this.$store.commit('namespaces/addNamespace', r)
|
this.$store.commit('namespaces/addNamespace', r)
|
||||||
this.success({message: 'The namespace was successfully created.'}, this)
|
this.success({message: 'The namespace was successfully created.'}, this)
|
||||||
this.$router.back()
|
|
||||||
this.closeQuickActions()
|
this.closeQuickActions()
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue