From c0d6d4f09617e5972756b35b8ee33e8306a88380 Mon Sep 17 00:00:00 2001 From: grnd-alt Date: Fri, 24 May 2024 15:20:14 +0200 Subject: [PATCH] update cloneBoards phpdoc make error message clear Signed-off-by: grnd-alt --- lib/Service/BoardService.php | 18 +++++++++++++----- .../navigation/AppNavigationBoard.vue | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index f89616a10..2a3e6afbc 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -479,6 +479,12 @@ public function deleteAcl(int $id): ?Acl { /** * @param $id * @param $userId + * @param $withCards + * @param $withAssignments + * @param $withLabels + * @param $withDueDate + * @param $moveCardsToLeftStack + * @param $restoreArchivedCards * @return Board * @throws DoesNotExistException * @throws \OCA\Deck\NoPermissionException @@ -492,9 +498,9 @@ public function clone($id, $userId, $withCards = false, $withAssignments = false throw new NoPermissionException('Creating boards has been disabled for your account.'); } - $this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ); + $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ); - $board = $this->boardMapper->find($boardId); + $board = $this->boardMapper->find($id); $newBoard = new Board(); $newBoard->setTitle($board->getTitle() . ' (' . $this->l10n->t('copy') . ')'); $newBoard->setOwner($userId); @@ -518,7 +524,7 @@ public function clone($id, $userId, $withCards = false, $withAssignments = false } - $labels = $this->labelMapper->findAll($boardId); + $labels = $this->labelMapper->findAll($id); foreach ($labels as $label) { $newLabel = new Label(); $newLabel->setTitle($label->getTitle()); @@ -527,7 +533,7 @@ public function clone($id, $userId, $withCards = false, $withAssignments = false $this->labelMapper->insert($newLabel); } - $stacks = $this->stackMapper->findAll($boardId); + $stacks = $this->stackMapper->findAll($id); foreach ($stacks as $stack) { $newStack = new Stack(); $newStack->setTitle($stack->getTitle()); @@ -654,7 +660,7 @@ private function cloneCards(Board $board, Board $newBoard, bool $withAssignments }); $newStacks = $this->stackMapper->findAll($newBoard->getId()); - usort($stacks, function (Stack $a, Stack $b) { + usort($newStacks, function (Stack $a, Stack $b) { return $a->getOrder() - $b->getOrder(); }); @@ -670,6 +676,7 @@ private function cloneCards(Board $board, Board $newBoard, bool $withAssignments $targetStackId = $moveCardsToLeftStack ? $newStacks[0]->getId() : $newStacks[$i]->getId(); // Create a cloned card. + // Done with setters as only fields set via setters get written to db $newCard = new Card(); $newCard->setTitle($card->getTitle()); $newCard->setDescription($card->getDescription()); @@ -680,6 +687,7 @@ private function cloneCards(Board $board, Board $newBoard, bool $withAssignments $newCard->setDuedate($withDueDate ? $card->getDuedate() : null); $newCard->setArchived($restoreArchivedCards ? false : $card->getArchived()); $newCard->setStackId($targetStackId); + $newCard->setAssignedUsers($card->getAssignedUsers()); // Persist the cloned card. $newCard = $this->cardMapper->insert($newCard); diff --git a/src/components/navigation/AppNavigationBoard.vue b/src/components/navigation/AppNavigationBoard.vue index d38e450b2..1221ed576 100644 --- a/src/components/navigation/AppNavigationBoard.vue +++ b/src/components/navigation/AppNavigationBoard.vue @@ -270,7 +270,7 @@ export default { this.loading = false await this.$router.push({ name: 'board', params: { id: newBoard.id } }) } catch (e) { - OC.Notification.showTemporary(t('deck', 'An error occurred')) + OC.Notification.showTemporary(t('deck', `Failed to clone board ${this.board.title}`)) console.error(e) } }