diff --git a/docs/API.md b/docs/API.md index dfa6d6c66..97db2c0bb 100644 --- a/docs/API.md +++ b/docs/API.md @@ -492,6 +492,19 @@ The board list endpoint supports setting an `If-Modified-Since` header to limit ##### 200 Success +### POST /boards/{boardId}/stacks/{stackId}/clone - Clone a stack + +#### Request parameters + +| Parameter | Type | Description | +| --------- | ------- | ---------------------------------------- | +| boardId | Integer | The id of the board the stack belongs to | +| stackId | Integer | The id of the stack | + +#### Response + +##### 200 Success + ## Cards ### GET /boards/{boardId}/stacks/{stackId}/cards/{cardId} - Get card details diff --git a/lib/Service/StackService.php b/lib/Service/StackService.php index bc19211c6..7cd0e2b12 100644 --- a/lib/Service/StackService.php +++ b/lib/Service/StackService.php @@ -44,7 +44,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use OCP\IL10N; use OCA\Deck\Event\FTSEvent; -use OCA\Deck\Service\AssignmentService; class StackService { private $stackMapper; @@ -63,7 +62,7 @@ class StackService { private $eventDispatcher; private $changeHelper; private $l10n; - private $assignmentService; + private $userId; public function __construct( StackMapper $stackMapper, @@ -80,7 +79,7 @@ class StackService { EventDispatcherInterface $eventDispatcher, ChangeHelper $changeHelper, IL10N $l10n, - AssignmentService $assignmentService + $userId ) { $this->stackMapper = $stackMapper; $this->boardMapper = $boardMapper; @@ -96,7 +95,7 @@ class StackService { $this->eventDispatcher = $eventDispatcher; $this->changeHelper = $changeHelper; $this->l10n = $l10n; - $this->assignmentService = $assignmentService; + $this->userId = $userId; } private function enrichStackWithCards($stack, $since = -1) { @@ -381,12 +380,11 @@ class StackService { /** * @param $id * @param $boardId - * @param $userId * @return Stack * @throws StatusException * @throws BadRequestException */ - public function clone($id, $boardId, $userId) { + public function clone($id, $boardId) { if (is_numeric($id) === false) { throw new BadRequestException('stack id must be a number'); } @@ -395,7 +393,6 @@ class StackService { } $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); - $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ); if ($this->boardService->isArchived(null, $boardId)) { throw new StatusException('Operation not allowed. This board is archived.'); } @@ -429,7 +426,7 @@ class StackService { $newCard->setStackId($newStack->getId()); $newCard->setType($card->getType()); $newCard->setOrder($card->getOrder()); - $newCard->setOwner($userId); + $newCard->setOwner($this->userId); $newCard->setDescription($card->getDescription()); $newCard->setDuedate($card->getDuedate()); @@ -439,7 +436,7 @@ class StackService { $this->changeHelper->cardChanged($newCard->getId(), false); $this->eventDispatcher->dispatch('\OCA\Deck\Card::onCreate', new FTSEvent( - null, ['id' => $newCard->getId(), 'card' => $newCard, 'userId' => $owner, 'stackId' => $stackId] + null, ['id' => $newCard->getId(), 'card' => $newCard, 'userId' => $this->userId, 'stackId' => $stackId] ) ); @@ -470,7 +467,6 @@ class StackService { $newUserArray[] = $assignment; } $newCard->setAssignedUsers($newUserArray); - $newCardArray[] = $newCard; } diff --git a/src/components/board/Stack.vue b/src/components/board/Stack.vue index 0832d0335..70d8823a1 100644 --- a/src/components/board/Stack.vue +++ b/src/components/board/Stack.vue @@ -42,14 +42,14 @@ value=""> - - + + {{ t('deck', 'Archive all cards') }} - + {{ t('deck', 'Clone list') }} - + {{ t('deck', 'Delete list') }} @@ -218,7 +218,11 @@ export default { this.modalArchivAllCardsShow = false }, cloneStack(stack) { - this.$store.dispatch('cloneStack', stack) + try { + this.$store.dispatch('cloneStack', stack) + } catch (e) { + showError('Could not clone stack: ' + e.response.data.message) + } }, startEditing(stack) { this.copiedStack = Object.assign({}, stack)