Make sure to not use the computed property
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
kolaente 2020-09-29 22:19:57 +02:00
parent 60ffa462a9
commit d7761732e0
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 17 additions and 15 deletions

View File

@ -44,6 +44,7 @@ import TaskAssigneeService from '../../../services/taskAssignee'
import User from '../../misc/user' import User from '../../misc/user'
import LoadingComponent from '../../misc/loading' import LoadingComponent from '../../misc/loading'
import ErrorComponent from '../../misc/error' import ErrorComponent from '../../misc/error'
import {CURRENT_TASK} from '@/store/mutation-types'
export default { export default {
name: 'editAssignees', name: 'editAssignees',
@ -96,6 +97,11 @@ export default {
methods: { methods: {
addAssignee(user) { addAssignee(user) {
this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId}) this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId})
.then(() => {
const task = this.$store.state[CURRENT_TASK]
task.assignees = this.assignees
this.$store.commit(CURRENT_TASK, task)
})
.catch(e => { .catch(e => {
this.error(e, this) this.error(e, this)
}) })
@ -109,6 +115,9 @@ export default {
this.assignees.splice(a, 1) this.assignees.splice(a, 1)
} }
} }
const task = this.$store.state[CURRENT_TASK]
task.assignees = this.assignees
this.$store.commit(CURRENT_TASK, task)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e, this)

View File

@ -50,7 +50,7 @@ export default {
.then(r => { .then(r => {
const t = ctx.rootGetters['kanban/getTaskById'](taskId) const t = ctx.rootGetters['kanban/getTaskById'](taskId)
if (t.task === null) { if (t.task === null) {
// Don't try further adding a label if the task is not in kanban // Don't try further adding an assignee if the task is not in kanban
// Usually this means the kanban board hasn't been accessed until now. // Usually this means the kanban board hasn't been accessed until now.
// Vuex seems to have its difficulties with that, so we just log the error and fail silently. // Vuex seems to have its difficulties with that, so we just log the error and fail silently.
console.debug('Could not add assignee to task in kanban, task not found', t) console.debug('Could not add assignee to task in kanban, task not found', t)

View File

@ -360,7 +360,6 @@
<script> <script>
import TaskService from '../../services/task' import TaskService from '../../services/task'
import TaskModel from '../../models/task'
import relationKinds from '../../models/relationKinds.json' import relationKinds from '../../models/relationKinds.json'
import priorites from '../../models/priorities.json' import priorites from '../../models/priorities.json'
@ -415,7 +414,6 @@ export default {
return { return {
taskId: Number(this.$route.params.id), taskId: Number(this.$route.params.id),
taskService: TaskService, taskService: TaskService,
//task: TaskModel,
relationKinds: relationKinds, relationKinds: relationKinds,
// The due date is a seperate property in the task to prevent flatpickr from modifying the task model // The due date is a seperate property in the task to prevent flatpickr from modifying the task model
// in store right after updating it from the api resulting in the wrong due date format being saved in the task. // in store right after updating it from the api resulting in the wrong due date format being saved in the task.
@ -463,7 +461,6 @@ export default {
}, },
created() { created() {
this.taskService = new TaskService() this.taskService = new TaskService()
// this.task = new TaskModel()
}, },
mounted() { mounted() {
@ -502,7 +499,7 @@ export default {
this.taskId = Number(this.$route.params.id) this.taskId = Number(this.$route.params.id)
this.taskService.get({id: this.taskId}) this.taskService.get({id: this.taskId})
.then(r => { .then(r => {
this.$set(this, 'task', r) this.$store.commit(CURRENT_TASK, r)
this.$store.commit('attachments/set', r.attachments) this.$store.commit('attachments/set', r.attachments)
this.taskTitle = this.task.title this.taskTitle = this.task.title
this.taskColor = this.task.hexColor this.taskColor = this.task.hexColor
@ -514,13 +511,11 @@ export default {
}) })
}, },
setActiveFields() { setActiveFields() {
const task = this.task
// TODO: Make sure all modifications to the current task are made through the store
// -> Setter
this.dueDate = this.task.dueDate ? this.task.dueDate : null this.dueDate = this.task.dueDate ? this.task.dueDate : null
// this.task.startDate = this.task.startDate ? this.task.startDate : null task.startDate = this.task.startDate ? this.task.startDate : null
// this.task.endDate = this.task.endDate ? this.task.endDate : null task.endDate = this.task.endDate ? this.task.endDate : null
this.$store.commit(CURRENT_TASK, task)
// Set all active fields based on values in the model // Set all active fields based on values in the model
this.activeFields.assignees = this.task.assignees.length > 0 this.activeFields.assignees = this.task.assignees.length > 0
@ -574,11 +569,9 @@ export default {
this.$store.commit(CURRENT_TASK, task) this.$store.commit(CURRENT_TASK, task)
console.log(this.task.assignees)
this.$store.dispatch('tasks/update', this.task) this.$store.dispatch('tasks/update', this.task)
.then(r => { .then(r => {
this.$set(this, 'task', r) this.$store.commit(CURRENT_TASK, r)
let actions = [] let actions = []
if (undoCallback !== null) { if (undoCallback !== null) {
actions = [{ actions = [{
@ -613,7 +606,7 @@ export default {
}) })
}, },
toggleTaskDone() { toggleTaskDone() {
const task = task const task = this.task
task.done = !this.task.done task.done = !this.task.done
this.$store.commit(CURRENT_TASK, task) this.$store.commit(CURRENT_TASK, task)
this.saveTask(() => this.toggleTaskDone()) this.saveTask(() => this.toggleTaskDone())