From 1d54fc3ae88a115f704298506f358ae4512831de Mon Sep 17 00:00:00 2001 From: Jakob Date: Sat, 19 Oct 2019 14:27:00 +0200 Subject: [PATCH] tried to move loadBoard to store Signed-off-by: Jakob --- src/components/board/Board.vue | 11 +++++++++-- src/store/main.js | 11 +++++++++++ src/store/stack.js | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/components/board/Board.vue b/src/components/board/Board.vue index 56d810155..bbf397b96 100644 --- a/src/components/board/Board.vue +++ b/src/components/board/Board.vue @@ -90,14 +90,21 @@ export default { }, methods: { fetchData() { - this.boardApi.loadById(this.id) + + this.$store.dispatch('loadBoardById', this.id).then(response => { + this.$store.dispatch('loadStacks', this.id).then(response => { + this.loading = false + }) + }) + + /* this.boardApi.loadById(this.id) .then((board) => { this.$store.dispatch('setCurrentBoard', board) this.$store.dispatch('loadStacks', board) this.$store.dispatch('setAssignableUsers', board.users) this.loading = false this.$store.state.labels = board.labels - }) + }) */ }, onDropStack({ removedIndex, addedIndex }) { this.$store.dispatch('orderStack', { stack: this.stacksByBoard[removedIndex], removedIndex, addedIndex }) diff --git a/src/store/main.js b/src/store/main.js index 92d50ff5a..947bd2ac5 100644 --- a/src/store/main.js +++ b/src/store/main.js @@ -235,6 +235,14 @@ export default new Vuex.Store({ } }, actions: { + loadBoardById({ commit }, boardId) { + apiClient.loadById(boardId) + .then((board) => { + commit('setCurrentBoard', board) + commit('setAssignableUsers', board.users) + }) + }, + toggleShowArchived({ commit }) { commit('toggleShowArchived') }, @@ -381,6 +389,9 @@ export default new Vuex.Store({ apiClient.addAcl(newAcl) .then((returnAcl) => { commit('addAclToCurrentBoard', returnAcl) + this.$store.dispatch('loadBoardById', newAcl.boardId).then(() => { + + }) }) }, updateAclFromCurrentBoard({ commit }, acl) { diff --git a/src/store/stack.js b/src/store/stack.js index 661c20440..2c30ac6dc 100644 --- a/src/store/stack.js +++ b/src/store/stack.js @@ -88,13 +88,13 @@ export default { commit('orderStack', { stack, addedIndex, removedIndex }) }) }, - loadStacks({ commit }, board) { + loadStacks({ commit }, boardId) { commit('clearCards') let call = 'loadStacks' if (this.state.showArchived === true) { call = 'loadArchivedStacks' } - apiClient[call](board.id) + apiClient[call](boardId) .then((stacks) => { for (let i in stacks) { let stack = stacks[i]