Clone boards with stacks, labels (#1221)

Clone boards with stacks, labels
This commit is contained in:
Julius Härtl
2019-10-10 09:03:34 +02:00
committed by GitHub
8 changed files with 110 additions and 3 deletions

View File

@@ -130,6 +130,25 @@ export default {
text: t('deck', 'Edit board')
})
actions.push({
action: async() => {
this.hideMenu()
this.loading = true
try {
const newBoard = await this.$store.dispatch('cloneBoard', this.board)
this.loading = false
const route = this.routeTo
route.params.id = newBoard.id
this.$router.push(route)
} catch (e) {
OC.Notification.showTemporary(t('deck', 'An error occurred'))
console.error(e)
}
},
icon: 'icon-clone',
text: t('deck', 'Clone board')
})
if (!this.board.archived) {
actions.push({
action: () => {

View File

@@ -135,6 +135,15 @@ export class BoardApi {
})
}
async cloneBoard(board) {
try {
let response = await axios.post(this.url(`/boards/${board.id}/clone`))
return response.data
} catch (err) {
return err
}
}
// Label API Calls
deleteLabel(id) {
return axios.delete(this.url(`/labels/${id}`))

View File

@@ -115,6 +115,19 @@ export default new Vuex.Store({
state.boards.push(board)
}
},
cloneBoard(state, board) {
const indexExisting = state.boards.findIndex((b) => {
return board.id === b.id
})
if (indexExisting > -1) {
Vue.set(state.boards, indexExisting, board)
} else {
state.boards.push(board)
}
},
/**
* Removes the board from the store.
*
@@ -268,6 +281,15 @@ export default new Vuex.Store({
commit('addBoard', board)
})
},
async cloneBoard({ commit }, boardData) {
try {
let newBoard = await apiClient.cloneBoard(boardData)
commit('cloneBoard', newBoard)
return newBoard
} catch (err) {
return err
}
},
removeBoard({ commit }, board) {
commit('removeBoard', board)
},