Use router parameter to trigger card change

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-08-12 10:47:11 +02:00
parent 2d35d90999
commit 781e2b0bb2
4 changed files with 40 additions and 11 deletions

View File

@@ -80,9 +80,8 @@ export default {
} */ } */
}, },
watch: { watch: {
'$route': 'fetchData', id: 'fetchData',
showArchived() { showArchived() {
this.fetchData() this.fetchData()
} }
}, },

View File

@@ -63,6 +63,11 @@ export default {
DeletedTabSidebar, DeletedTabSidebar,
TimelineTabSidebard TimelineTabSidebard
}, },
props: {
id: {
type: Number
}
},
computed: { computed: {
...mapState({ ...mapState({
board: state => state.currentBoard, board: state => state.currentBoard,

View File

@@ -21,7 +21,7 @@
--> -->
<template> <template>
<app-sidebar v-if="currentCard != null" <app-sidebar v-if="currentCard !== null && copiedCard !== null"
:actions="toolbarActions" :actions="toolbarActions"
:title="currentCard.title" :title="currentCard.title"
@close="closeSidebar"> @close="closeSidebar">
@@ -89,6 +89,11 @@ export default {
DatetimePicker, DatetimePicker,
markdownEditor markdownEditor
}, },
props: {
id: {
type: Number
}
},
data() { data() {
return { return {
assignedUsers: null, assignedUsers: null,
@@ -101,10 +106,12 @@ export default {
}, },
computed: { computed: {
...mapState({ ...mapState({
currentCard: state => state.currentCard,
currentBoard: state => state.currentBoard, currentBoard: state => state.currentBoard,
assignableUsers: state => state.assignableUsers assignableUsers: state => state.assignableUsers
}), }),
currentCard() {
return this.$store.getters.cardById(this.id)
},
subtitle() { subtitle() {
let lastModified = this.currentCard.lastModified let lastModified = this.currentCard.lastModified
let createdAt = this.currentCard.createdAt let createdAt = this.currentCard.createdAt
@@ -131,11 +138,15 @@ export default {
} }
}, },
watch: { watch: {
currentCard() { 'currentCard': {
this.copiedCard = JSON.parse(JSON.stringify(this.currentCard)) immediate: true,
this.allLabels = this.currentCard.labels handler() {
this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant) console.log(this.currentCard)
this.desc = this.currentCard.description this.copiedCard = JSON.parse(JSON.stringify(this.currentCard))
this.allLabels = this.currentCard.labels
this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant)
this.desc = this.currentCard.description
}
}, },
desc() { desc() {
this.copiedCard.description = this.desc this.copiedCard.description = this.desc

View File

@@ -86,14 +86,28 @@ export default new Router({
components: { components: {
default: Boards, default: Boards,
sidebar: BoardSidebar sidebar: BoardSidebar
} },
props: {
default: (route) => {
return {
id: parseInt(route.params.id, 10)
}
}
},
}, },
{ {
path: 'cards/:cardId', path: 'cards/:cardId',
name: 'card', name: 'card',
components: { components: {
sidebar: CardSidebar sidebar: CardSidebar
} },
props: {
sidebar: (route) => {
return {
id: parseInt(route.params.cardId, 10)
}
}
},
} }
] ]
} }