tried to move loadBoard to store

Signed-off-by: Jakob <jakob.roehrl@web.de>
This commit is contained in:
Jakob
2019-10-19 14:27:00 +02:00
parent 23e88a7e15
commit 1d54fc3ae8
3 changed files with 22 additions and 4 deletions

View File

@@ -90,14 +90,21 @@ export default {
}, },
methods: { methods: {
fetchData() { 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) => { .then((board) => {
this.$store.dispatch('setCurrentBoard', board) this.$store.dispatch('setCurrentBoard', board)
this.$store.dispatch('loadStacks', board) this.$store.dispatch('loadStacks', board)
this.$store.dispatch('setAssignableUsers', board.users) this.$store.dispatch('setAssignableUsers', board.users)
this.loading = false this.loading = false
this.$store.state.labels = board.labels this.$store.state.labels = board.labels
}) }) */
}, },
onDropStack({ removedIndex, addedIndex }) { onDropStack({ removedIndex, addedIndex }) {
this.$store.dispatch('orderStack', { stack: this.stacksByBoard[removedIndex], removedIndex, addedIndex }) this.$store.dispatch('orderStack', { stack: this.stacksByBoard[removedIndex], removedIndex, addedIndex })

View File

@@ -235,6 +235,14 @@ export default new Vuex.Store({
} }
}, },
actions: { actions: {
loadBoardById({ commit }, boardId) {
apiClient.loadById(boardId)
.then((board) => {
commit('setCurrentBoard', board)
commit('setAssignableUsers', board.users)
})
},
toggleShowArchived({ commit }) { toggleShowArchived({ commit }) {
commit('toggleShowArchived') commit('toggleShowArchived')
}, },
@@ -381,6 +389,9 @@ export default new Vuex.Store({
apiClient.addAcl(newAcl) apiClient.addAcl(newAcl)
.then((returnAcl) => { .then((returnAcl) => {
commit('addAclToCurrentBoard', returnAcl) commit('addAclToCurrentBoard', returnAcl)
this.$store.dispatch('loadBoardById', newAcl.boardId).then(() => {
})
}) })
}, },
updateAclFromCurrentBoard({ commit }, acl) { updateAclFromCurrentBoard({ commit }, acl) {

View File

@@ -88,13 +88,13 @@ export default {
commit('orderStack', { stack, addedIndex, removedIndex }) commit('orderStack', { stack, addedIndex, removedIndex })
}) })
}, },
loadStacks({ commit }, board) { loadStacks({ commit }, boardId) {
commit('clearCards') commit('clearCards')
let call = 'loadStacks' let call = 'loadStacks'
if (this.state.showArchived === true) { if (this.state.showArchived === true) {
call = 'loadArchivedStacks' call = 'loadArchivedStacks'
} }
apiClient[call](board.id) apiClient[call](boardId)
.then((stacks) => { .then((stacks) => {
for (let i in stacks) { for (let i in stacks) {
let stack = stacks[i] let stack = stacks[i]