Add creating a new task cmd

This commit is contained in:
kolaente 2021-05-30 17:29:23 +02:00
parent 1cebe3ca8b
commit 8f94c64e10
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 33 additions and 2 deletions

View File

@ -86,7 +86,7 @@ export default {
this.$route.name === 'user.settings' ||
this.$route.name === 'namespaces.index'
) {
this.$store.commit(CURRENT_LIST, {})
this.$store.commit(CURRENT_LIST, null)
}
},
renewTokenOnFocus() {

View File

@ -50,9 +50,12 @@ import ListService from '@/services/list'
import NamespaceService from '@/services/namespace'
import TeamService from '@/services/team'
import TaskModel from '@/models/task'
import NamespaceModel from '@/models/namespace'
import TeamModel from '@/models/team'
import {CURRENT_LIST} from '@/store/mutation-types'
const TYPE_LIST = 'list'
const TYPE_TASK = 'task'
const TYPE_CMD = 'cmd'
@ -157,6 +160,9 @@ export default {
return 'Type a command or search...'
},
currentList() {
return Object.keys(this.$store.state[CURRENT_LIST]).length === 0 ? null : this.$store.state[CURRENT_LIST]
},
},
created() {
this.taskService = new TaskService()
@ -229,6 +235,22 @@ export default {
}
},
newTask() {
if (this.currentList === null) {
return
}
const newTask = new TaskModel({
title: this.query,
listId: this.currentList.id,
})
this.taskService.create(newTask)
.then(r => {
this.success({message: 'The task was successfully created.'}, this)
this.$router.push({name: 'task.detail', params: {id: r.id}})
})
.catch((e) => {
this.error(e, this)
})
},
newList() {
},

View File

@ -61,6 +61,12 @@ export const store = new Vuex.Store({
},
[CURRENT_LIST](state, currentList) {
if (currentList === null) {
state.currentList = {}
state.background = null
return
}
setTitle(currentList.title)
// Not sure if this is the right way to do it but hey, it works

View File

@ -429,6 +429,7 @@ import heading from '@/components/tasks/partials/heading'
import Datepicker from '@/components/input/datepicker'
import {playPop} from '@/helpers/playPop'
import TaskSubscription from '@/components/misc/subscription'
import {CURRENT_LIST} from '@/store/mutation-types'
export default {
name: 'TaskDetailView',
@ -520,7 +521,9 @@ export default {
return null
}
return this.$store.getters['namespaces/getListAndNamespaceById'](this.task.listId)
const list = this.$store.getters['namespaces/getListAndNamespaceById'](this.task.listId)
this.$store.commit(CURRENT_LIST, list)
return list
},
canWrite() {
return this.task && this.task.maxRight && this.task.maxRight > rights.READ