fix: remove broken getTaskIndices helper
This commit is contained in:
parent
0b68a473ef
commit
e0456cdfa1
1 changed files with 15 additions and 24 deletions
|
@ -10,26 +10,6 @@ import TaskCollectionService from '@/services/taskCollection'
|
||||||
|
|
||||||
const TASKS_PER_BUCKET = 25
|
const TASKS_PER_BUCKET = 25
|
||||||
|
|
||||||
function getTaskIndices(state, task) {
|
|
||||||
const bucketIndex = findIndexById(state.buckets, task.bucketId)
|
|
||||||
|
|
||||||
if (!bucketIndex) {
|
|
||||||
throw('Bucket not found')
|
|
||||||
}
|
|
||||||
|
|
||||||
const bucket = state.buckets[bucketIndex]
|
|
||||||
const taskIndex = findIndexById(bucket.tasks, task.id)
|
|
||||||
|
|
||||||
if (!bucketIndex) {
|
|
||||||
throw('Task not found')
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
bucketIndex,
|
|
||||||
taskIndex,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const addTaskToBucketAndSort = (state, task) => {
|
const addTaskToBucketAndSort = (state, task) => {
|
||||||
const bucketIndex = findIndexById(state.buckets, task.bucketId)
|
const bucketIndex = findIndexById(state.buckets, task.bucketId)
|
||||||
state.buckets[bucketIndex].tasks.push(task)
|
state.buckets[bucketIndex].tasks.push(task)
|
||||||
|
@ -172,9 +152,19 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { bucketIndex, taskIndex } = getTaskIndices(state, task)
|
for (const b in state.buckets) {
|
||||||
|
if (state.buckets[b].id === task.bucketId) {
|
||||||
state.buckets[bucketIndex].tasks.splice(taskIndex, 1)
|
for (const t in state.buckets[b].tasks) {
|
||||||
|
if (state.buckets[b].tasks[t].id === task.id) {
|
||||||
|
const bucket = state.buckets[b]
|
||||||
|
bucket.tasks.splice(t, 1)
|
||||||
|
state.buckets[b] = bucket
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setBucketLoading(state, {bucketId, loading}) {
|
setBucketLoading(state, {bucketId, loading}) {
|
||||||
|
@ -367,6 +357,7 @@ export default {
|
||||||
const bucketService = new BucketService()
|
const bucketService = new BucketService()
|
||||||
return bucketService.update(updatedBucket)
|
return bucketService.update(updatedBucket)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
|
ctx.commit('setBucketByIndex', {bucketIndex, bucket: r})
|
||||||
Promise.resolve(r)
|
Promise.resolve(r)
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
|
Loading…
Reference in a new issue