feat: review changes
This commit is contained in:
parent
50fa592aad
commit
fa54e1f1de
2 changed files with 28 additions and 40 deletions
|
@ -74,7 +74,7 @@ export default {
|
||||||
this.assignees = value
|
this.assignees = value
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
deept: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -10,6 +10,19 @@ import TaskCollectionService from '@/services/taskCollection'
|
||||||
|
|
||||||
const TASKS_PER_BUCKET = 25
|
const TASKS_PER_BUCKET = 25
|
||||||
|
|
||||||
|
function getTaskIndicesById(state, taskId) {
|
||||||
|
let taskIndex
|
||||||
|
const bucketIndex = state.buckets.findIndex(({ tasks }) => {
|
||||||
|
taskIndex = findIndexById(tasks, taskId)
|
||||||
|
return taskIndex !== -1
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
bucketIndex: bucketIndex !== -1 ? bucketIndex : null,
|
||||||
|
taskIndex: taskIndex !== -1 ? taskIndex : null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -152,19 +165,16 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const b in state.buckets) {
|
const { bucketIndex, taskIndex } = getTaskIndicesById(state, task.id)
|
||||||
if (state.buckets[b].id === task.bucketId) {
|
|
||||||
for (const t in state.buckets[b].tasks) {
|
if (
|
||||||
if (state.buckets[b].tasks[t].id === task.id) {
|
state.buckets[bucketIndex]?.id !== task.bucketId ||
|
||||||
const bucket = state.buckets[b]
|
state.buckets[bucketIndex]?.tasks[taskIndex]?.id !== task.id
|
||||||
bucket.tasks.splice(t, 1)
|
) {
|
||||||
state.buckets[b] = bucket
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.buckets[bucketIndex].tasks.splice(taskIndex, 1)
|
||||||
},
|
},
|
||||||
|
|
||||||
setBucketLoading(state, {bucketId, loading}) {
|
setBucketLoading(state, {bucketId, loading}) {
|
||||||
|
@ -187,15 +197,11 @@ export default {
|
||||||
|
|
||||||
getTaskById(state) {
|
getTaskById(state) {
|
||||||
return (id) => {
|
return (id) => {
|
||||||
let taskIndex
|
const { bucketIndex, taskIndex } = getTaskIndicesById(state, id)
|
||||||
const bucketIndex = state.buckets.findIndex(({ tasks }) => {
|
|
||||||
taskIndex = findIndexById(tasks, id)
|
|
||||||
return taskIndex !== -1
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bucketIndex: bucketIndex !== -1 ? bucketIndex : null,
|
bucketIndex,
|
||||||
taskIndex: taskIndex !== -1 ? taskIndex : null,
|
taskIndex,
|
||||||
task: state.buckets[bucketIndex]?.tasks?.[taskIndex] || null,
|
task: state.buckets[bucketIndex]?.tasks?.[taskIndex] || null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,15 +255,6 @@ export default {
|
||||||
params.sort_by = 'kanban_position'
|
params.sort_by = 'kanban_position'
|
||||||
params.order_by = 'asc'
|
params.order_by = 'asc'
|
||||||
|
|
||||||
// const hasBucketFilter = Object.entries(params.filter_by).some(([key, value]) => {
|
|
||||||
// const condition = value === 'bucket_id'
|
|
||||||
// if (condition) {
|
|
||||||
// if (value !== bucketId) {
|
|
||||||
// params.filter_value[key] = bucketId
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return condition
|
|
||||||
// })
|
|
||||||
let hasBucketFilter = false
|
let hasBucketFilter = false
|
||||||
for (const f in params.filter_by) {
|
for (const f in params.filter_by) {
|
||||||
if (params.filter_by[f] === 'bucket_id') {
|
if (params.filter_by[f] === 'bucket_id') {
|
||||||
|
@ -338,20 +335,11 @@ export default {
|
||||||
const bucketIndex = findIndexById(ctx.state.buckets, updatedBucketData.id)
|
const bucketIndex = findIndexById(ctx.state.buckets, updatedBucketData.id)
|
||||||
const oldBucket = cloneDeep(ctx.state.buckets[bucketIndex])
|
const oldBucket = cloneDeep(ctx.state.buckets[bucketIndex])
|
||||||
|
|
||||||
const bucket = ctx.state.buckets[bucketIndex]
|
const updatedBucket = {
|
||||||
|
...ctx.state.buckets[bucketIndex],
|
||||||
const requestData = {
|
|
||||||
id: updatedBucketData.id,
|
|
||||||
listId: updatedBucketData.listId || oldBucket.listId,
|
|
||||||
title: oldBucket.title, // can't be empty in request
|
|
||||||
// ...bucket,
|
|
||||||
...updatedBucketData,
|
...updatedBucketData,
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedBucket = {
|
|
||||||
...bucket,
|
|
||||||
...requestData,
|
|
||||||
}
|
|
||||||
ctx.commit('setBucketByIndex', {bucketIndex, bucket: updatedBucket})
|
ctx.commit('setBucketByIndex', {bucketIndex, bucket: updatedBucket})
|
||||||
|
|
||||||
const bucketService = new BucketService()
|
const bucketService = new BucketService()
|
||||||
|
|
Loading…
Reference in a new issue