Able to set description on creation card via API.
Signed-off-by: alexandru.puiu <alexandrup@newro.co>
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* @copyright Copyright (c) 2018 Ryan Fletcher <ryan.fletcher@codepassion.ca>
|
* @copyright Copyright (c) 2018 Ryan Fletcher <ryan.fletcher@codepassion.ca>
|
||||||
*
|
*
|
||||||
|
* @copyright Copyright (c) 2019, Alexandru Puiu (alexpuiu20@yahoo.com)
|
||||||
|
*
|
||||||
* @author Ryan Fletcher <ryan.fletcher@codepassion.ca>
|
* @author Ryan Fletcher <ryan.fletcher@codepassion.ca>
|
||||||
*
|
*
|
||||||
* @license GNU AGPL version 3 or any later version
|
* @license GNU AGPL version 3 or any later version
|
||||||
@@ -70,11 +72,12 @@ class CardApiController extends ApiController {
|
|||||||
* @params $title
|
* @params $title
|
||||||
* @params $type
|
* @params $type
|
||||||
* @params $order
|
* @params $order
|
||||||
|
* @params $description
|
||||||
*
|
*
|
||||||
* Get a specific card.
|
* Get a specific card.
|
||||||
*/
|
*/
|
||||||
public function create($title, $type = 'plain', $order = 999) {
|
public function create($title, $type = 'plain', $order = 999, $description) {
|
||||||
$card = $this->cardService->create($title, $this->request->getParam('stackId'), $type, $order, $this->userId);
|
$card = $this->cardService->create($title, $this->request->getParam('stackId'), $type, $order, $this->userId, $description);
|
||||||
return new DataResponse($card, HTTP::STATUS_OK);
|
return new DataResponse($card, HTTP::STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
|
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
|
||||||
*
|
*
|
||||||
|
* @copyright Copyright (c) 2019, Alexandru Puiu (alexpuiu20@yahoo.com)
|
||||||
|
*
|
||||||
* @author Julius Härtl <jus@bitgrid.net>
|
* @author Julius Härtl <jus@bitgrid.net>
|
||||||
* @author Maxence Lange <maxence@artificial-owl.com>
|
* @author Maxence Lange <maxence@artificial-owl.com>
|
||||||
*
|
*
|
||||||
@@ -147,6 +149,7 @@ class CardService {
|
|||||||
* @param $stackId
|
* @param $stackId
|
||||||
* @param $type
|
* @param $type
|
||||||
* @param integer $order
|
* @param integer $order
|
||||||
|
* @param $description
|
||||||
* @param $owner
|
* @param $owner
|
||||||
* @return \OCP\AppFramework\Db\Entity
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
* @throws StatusException
|
* @throws StatusException
|
||||||
@@ -155,8 +158,7 @@ class CardService {
|
|||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
* @throws BadrequestException
|
* @throws BadrequestException
|
||||||
*/
|
*/
|
||||||
public function create($title, $stackId, $type, $order, $owner) {
|
public function create($title, $stackId, $type, $order, $owner, $description = '') {
|
||||||
|
|
||||||
if ($title === 'false' || $title === null) {
|
if ($title === 'false' || $title === null) {
|
||||||
throw new BadRequestException('title must be provided');
|
throw new BadRequestException('title must be provided');
|
||||||
}
|
}
|
||||||
@@ -187,6 +189,7 @@ class CardService {
|
|||||||
$card->setType($type);
|
$card->setType($type);
|
||||||
$card->setOrder($order);
|
$card->setOrder($order);
|
||||||
$card->setOwner($owner);
|
$card->setOwner($owner);
|
||||||
|
$card->setDescription($description);
|
||||||
$card = $this->cardMapper->insert($card);
|
$card = $this->cardMapper->insert($card);
|
||||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_CREATE);
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_CREATE);
|
||||||
$this->changeHelper->cardChanged($card->getId(), false);
|
$this->changeHelper->cardChanged($card->getId(), false);
|
||||||
@@ -312,7 +315,7 @@ class CardService {
|
|||||||
// Trigger update events before setting description as it is handled separately
|
// Trigger update events before setting description as it is handled separately
|
||||||
$changes->setAfter($card);
|
$changes->setAfter($card);
|
||||||
$this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_CARD, $changes, ActivityManager::SUBJECT_CARD_UPDATE);
|
$this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_CARD, $changes, ActivityManager::SUBJECT_CARD_UPDATE);
|
||||||
|
|
||||||
if ($card->getDescriptionPrev() === null) {
|
if ($card->getDescriptionPrev() === null) {
|
||||||
$card->setDescriptionPrev($card->getDescription());
|
$card->setDescriptionPrev($card->getDescription());
|
||||||
}
|
}
|
||||||
@@ -321,7 +324,7 @@ class CardService {
|
|||||||
|
|
||||||
$card = $this->cardMapper->update($card);
|
$card = $this->cardMapper->update($card);
|
||||||
$this->changeHelper->cardChanged($card->getId(), true);
|
$this->changeHelper->cardChanged($card->getId(), true);
|
||||||
|
|
||||||
$this->eventDispatcher->dispatch(
|
$this->eventDispatcher->dispatch(
|
||||||
'\OCA\Deck\Card::onUpdate', new GenericEvent(null, ['id' => $id, 'card' => $card])
|
'\OCA\Deck\Card::onUpdate', new GenericEvent(null, ['id' => $id, 'card' => $card])
|
||||||
);
|
);
|
||||||
@@ -437,7 +440,7 @@ class CardService {
|
|||||||
if (is_numeric($id) === false) {
|
if (is_numeric($id) === false) {
|
||||||
throw new BadRequestException('id must be a number');
|
throw new BadRequestException('id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||||
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
if ($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||||
throw new StatusException('Operation not allowed. This board is archived.');
|
throw new StatusException('Operation not allowed. This board is archived.');
|
||||||
@@ -502,7 +505,7 @@ class CardService {
|
|||||||
if (is_numeric($cardId) === false) {
|
if (is_numeric($cardId) === false) {
|
||||||
throw new BadRequestException('card id must be a number');
|
throw new BadRequestException('card id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($labelId) === false) {
|
if (is_numeric($labelId) === false) {
|
||||||
throw new BadRequestException('label id must be a number');
|
throw new BadRequestException('label id must be a number');
|
||||||
}
|
}
|
||||||
@@ -594,7 +597,7 @@ class CardService {
|
|||||||
/* Notifyuser about the card assignment */
|
/* Notifyuser about the card assignment */
|
||||||
$this->notificationHelper->sendCardAssigned($card, $userId);
|
$this->notificationHelper->sendCardAssigned($card, $userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$assignment = new AssignedUsers();
|
$assignment = new AssignedUsers();
|
||||||
$assignment->setCardId($cardId);
|
$assignment->setCardId($cardId);
|
||||||
$assignment->setParticipant($userId);
|
$assignment->setParticipant($userId);
|
||||||
|
|||||||
Reference in New Issue
Block a user