change route after board duplication

Signed-off-by: Jakob <jakob.roehrl@web.de>
This commit is contained in:
Jakob
2019-10-09 08:42:28 +02:00
parent 31ae00708d
commit 71e7c98fd6
5 changed files with 25 additions and 15 deletions

View File

@@ -55,8 +55,8 @@
@if mixin-exists('icon-black-white') {
@include icon-black-white('deck', 'deck', 1);
@include icon-black-white('archive', 'deck', 1);
@include icon-black-white('deck', 'deck', 1);
@include icon-black-white('archive', 'deck', 1);
@include icon-black-white('circles', 'deck', 1);
@include icon-black-white('clone', 'deck', 1);

View File

@@ -153,7 +153,7 @@ class BoardController extends ApiController {
/**
* @NoAdminRequired
* @param $boardId
* @return \OCP\AppFramework\Db\Entity
* @return \OCP\Deck\DB\Board
*/
public function clone($boardId) {
return $this->boardService->clone($boardId);

View File

@@ -624,7 +624,7 @@ class BoardService {
$board = $this->boardMapper->find($id);
$newBoard = new Board();
$newBoard->setTitle($board->getTitle() . ' (copy)');
$newBoard->setTitle($board->getTitle() . ' (' . $this->l10n->t('copy') . ')');
$newBoard->setOwner($board->getOwner());
$newBoard->setColor($board->getColor());
$this->boardMapper->insert($newBoard);

View File

@@ -131,16 +131,20 @@ export default {
})
actions.push({
action: () => {
action: async () => {
this.hideMenu()
this.loading = true
this.$store.dispatch('cloneBoard', this.board).then((newBoard) => {
this.loading = false
this.editTitle = this.board.title
this.editColor = '#' + this.board.color
this.editing = 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 {
OC.Notification.showTemporary(t('deck', 'An error occurred'))
}
},
icon: 'icon-clone',
text: t('deck', 'Clone board')

View File

@@ -281,10 +281,16 @@ export default new Vuex.Store({
})
},
cloneBoard({ commit }, boardData) {
apiClient.cloneBoard(boardData)
.then((board) => {
commit('cloneBoard', board)
})
return new Promise((resolve, reject) => {
apiClient.cloneBoard(boardData)
.then((board) => {
commit('cloneBoard', board)
resolve(board)
})
.catch((err) => {
return reject(err)
})
})
},
removeBoard({ commit }, board) {
commit('removeBoard', board)