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: {
'$route': 'fetchData',
id: 'fetchData',
showArchived() {
this.fetchData()
}
},

View File

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

View File

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

View File

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