Skip to content

Commit 203576a

Browse files
committed
fix: switch board from menu not work
1 parent 8ea3e3f commit 203576a

File tree

1 file changed

+43
-22
lines changed

1 file changed

+43
-22
lines changed

front-end/src/views/BoardPage.vue

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,45 @@ export default {
9999
draggable
100100
},
101101
beforeRouteEnter (to, from, next) {
102-
boardService.getBoard(to.params.boardId).then(data => {
103-
next(vm => {
104-
vm.team.name = data.team ? data.team.name : ''
105-
vm.board.id = data.board.id
106-
vm.board.personal = data.board.personal
107-
vm.board.name = data.board.name
102+
next(vm => {
103+
vm.loadBoard()
104+
})
105+
},
106+
beforeRouteUpdate (to, from, next) {
107+
next()
108+
this.unsubscribeFromRealTimeUpdate()
109+
this.loadBoard()
110+
},
111+
beforeRouteLeave (to, from, next) {
112+
next()
113+
this.unsubscribeFromRealTimeUpdate()
114+
},
115+
mounted () {
116+
this.$el.addEventListener('click', this.dismissActiveForms)
117+
},
118+
beforeDestroy () {
119+
this.$el.removeEventListener('click', this.dismissActiveForms)
120+
},
121+
methods: {
122+
loadBoard () {
123+
console.log('[BoardPage] Loading board')
124+
boardService.getBoard(this.$route.params.boardId).then(data => {
125+
this.team.name = data.team ? data.team.name : ''
126+
this.board.id = data.board.id
127+
this.board.personal = data.board.personal
128+
this.board.name = data.board.name
129+
130+
this.members.splice(0)
108131
109132
data.members.forEach(member => {
110-
vm.members.push({
133+
this.members.push({
111134
id: member.userId,
112135
shortName: member.shortName
113136
})
114137
})
115138
139+
this.cardLists.splice(0)
140+
116141
data.cardLists.sort((list1, list2) => {
117142
return list1.position - list2.position
118143
})
@@ -122,7 +147,7 @@ export default {
122147
return card1.position - card2.position
123148
})
124149
125-
vm.cardLists.push({
150+
this.cardLists.push({
126151
id: cardList.id,
127152
name: cardList.name,
128153
cards: cardList.cards,
@@ -132,21 +157,11 @@ export default {
132157
}
133158
})
134159
})
135-
136-
vm.$rt.subscribe('/board/' + vm.board.id, vm.onRealTimeUpdated)
160+
this.subscribeToRealTimUpdate()
161+
}).catch(error => {
162+
notify.error(error.message)
137163
})
138-
}).catch(error => {
139-
notify.error(error.message)
140-
})
141-
},
142-
mounted () {
143-
this.$el.addEventListener('click', this.dismissActiveForms)
144-
},
145-
beforeDestroy () {
146-
this.$el.removeEventListener('click', this.dismissActiveForms)
147-
this.$rt.unsubscribe('/board/' + this.board.id, this.onRealTimeUpdated)
148-
},
149-
methods: {
164+
},
150165
dismissActiveForms (event) {
151166
console.log('[BoardPage] Dismissing forms')
152167
let dismissAddCardForm = true
@@ -287,6 +302,12 @@ export default {
287302
notify.error(error.message)
288303
})
289304
},
305+
subscribeToRealTimUpdate () {
306+
this.$rt.subscribe('/board/' + this.board.id, this.onRealTimeUpdated)
307+
},
308+
unsubscribeFromRealTimeUpdate () {
309+
this.$rt.unsubscribe('/board/' + this.board.id, this.onRealTimeUpdated)
310+
},
290311
onRealTimeUpdated (update) {
291312
console.log('[BoardPage] Real time update received', update)
292313
if (update.type === 'cardAdded') {

0 commit comments

Comments
 (0)