From 71e7c98fd6411f71a2cacf15525e965d4ced1712 Mon Sep 17 00:00:00 2001 From: Jakob Date: Wed, 9 Oct 2019 08:42:28 +0200 Subject: [PATCH] change route after board duplication Signed-off-by: Jakob --- css/icons.scss | 4 ++-- lib/Controller/BoardController.php | 2 +- lib/Service/BoardService.php | 2 +- .../navigation/AppNavigationBoard.vue | 18 +++++++++++------- src/store/main.js | 14 ++++++++++---- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/css/icons.scss b/css/icons.scss index f2b90dbf7..ef9755890 100644 --- a/css/icons.scss +++ b/css/icons.scss @@ -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); diff --git a/lib/Controller/BoardController.php b/lib/Controller/BoardController.php index b397c63d8..5a02477ab 100644 --- a/lib/Controller/BoardController.php +++ b/lib/Controller/BoardController.php @@ -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); diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index 8f5cc58af..e87576a92 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -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); diff --git a/src/components/navigation/AppNavigationBoard.vue b/src/components/navigation/AppNavigationBoard.vue index 474d7f81a..7c27e7cb4 100644 --- a/src/components/navigation/AppNavigationBoard.vue +++ b/src/components/navigation/AppNavigationBoard.vue @@ -131,16 +131,20 @@ export default { }) actions.push({ - action: () => { + action: async () => { this.hideMenu() this.loading = true - this.$store.dispatch('cloneBoard', this.board).then((newBoard) => { + try { + const newBoard = await this.$store.dispatch('cloneBoard', this.board) + this.loading = false - this.editTitle = this.board.title - this.editColor = '#' + this.board.color - this.editing = true - - }) + 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') diff --git a/src/store/main.js b/src/store/main.js index 4ae00740b..fb67ff39c 100644 --- a/src/store/main.js +++ b/src/store/main.js @@ -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)