diff --git a/src/views/list/views/Kanban.vue b/src/views/list/views/Kanban.vue index a78dd7b08..a81e6ba44 100644 --- a/src/views/list/views/Kanban.vue +++ b/src/views/list/views/Kanban.vue @@ -21,7 +21,7 @@ :key="`bucket${bucket.id}`" class="bucket" :class="{'is-collapsed': collapsedBuckets[bucket.id]}" - v-for="bucket in buckets" + v-for="(bucket, k) in buckets" >
- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -365,10 +365,28 @@ export default { this.error(e) }) }, - onDrop(bucketId, dropResult) { - console.log('drop', bucketId, dropResult) + updateTaskPosition(bucketIndex, e) { this.drag = false + const newBucket = this.buckets[bucketIndex] + const task = newBucket.tasks[e.newIndex] + const taskBefore = newBucket.tasks[e.newIndex - 1] ?? null + const taskAfter = newBucket.tasks[e.newIndex + 1] ?? null + + task.kanban_position = calculateItemPosition(taskBefore !== null ? taskBefore.position : null, taskAfter !== null ? taskAfter.position : null) + task.bucketId = newBucket.id + + this.$store.dispatch('tasks/update', task) + .catch(e => { + this.error(e) + }) + .finally(() => { + this.$set(this.taskUpdating, task.id, false) + this.oneTaskUpdating = false + }) + }, + onDrop(bucketId, dropResult) { + // Note: A lot of this example comes from the excellent kanban example on https://github.com/kutlugsahin/vue-smooth-dnd/blob/master/demo/src/pages/cards.vue // const bucketIndex = filterObject(this.buckets, b => b.id === bucketId)