diff --git a/src/components/board/Board.vue b/src/components/board/Board.vue index 55e1161a8..9d83334de 100644 --- a/src/components/board/Board.vue +++ b/src/components/board/Board.vue @@ -25,17 +25,23 @@
- - +

{{ stack.title }}

- - - + + + + +
+
+
+

{{ t('deck', 'Board not found')}}

+

+
@@ -44,7 +50,7 @@ import { Container, Draggable } from 'vue-smooth-dnd' import { mapState } from 'vuex' import Controls from '../Controls' -import Card from '../card/Card' +import CardItem from '../cards/CardItem' const applyDrag = (arr, dragResult) => { const { removedIndex, addedIndex, payload } = dragResult @@ -68,14 +74,15 @@ const dummyCard = function(i) { return { id: i, order: 0, - title: 'card ' + i + title: 'card ' + i, + stackId: 1 } } export default { name: 'Board', components: { - Card, + CardItem, Controls, Container, Draggable @@ -115,11 +122,26 @@ export default { }) }, methods: { - toggleSidebar: function() { - this.$store.dispatch('toggleSidebar') - }, onDropStack(dropResult) { + // TODO: persist new order in order field this.stacks = applyDrag(this.stacks, dropResult) + }, + onDropCard(stackId, dropResult) { + if (dropResult.removedIndex !== null || dropResult.addedIndex !== null) { + // TODO: persist new order in order field + const stacks = this.stacks + const stack = stacks.filter(p => p.id === stackId)[0] + const stackIndex = stacks.indexOf(stack) + const newStack = Object.assign({}, stack) + newStack.cards = applyDrag(newStack.cards, dropResult) + stacks.splice(stackIndex, 1, newStack) + this.stacks = stacks + } + }, + payload(stackId) { + return index => { + return this.stacks.find(stack => stack.id === stackId).cards[index] + } } } } @@ -127,4 +149,17 @@ export default {