Implemented StackApiController Get Function.

Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
Ryan Fletcher
2018-07-13 19:29:39 -04:00
committed by Julius Härtl
parent dd1d4246fe
commit cfd9ab98c6
3 changed files with 36 additions and 4 deletions

View File

@@ -86,6 +86,7 @@ return [
['name' => 'board_api#undo_delete', 'url' => '/api/v1.0/boards/{boardId}/undo_delete', 'verb' => 'POST'],
['name' => 'stack_api#index', 'url' => '/api/v1.0/boards/{boardId}/stacks', 'verb' => 'GET'],
['name' => 'stack_api#index', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}', 'verb' => 'GET'],
['name' => 'stack_api#create', 'url' => '/api/v1.0/boards/{boardId}/stacks', 'verb' => 'POST'],
['name' => 'stack_api#update', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}', 'verb' => 'PUT'],
['name' => 'stack_api#delete', 'url' => '/api/v1.0/boards/{boardId}/stacks/{stackId}', 'verb' => 'DELETE'],

View File

@@ -66,7 +66,7 @@ class StackApiController extends ApiController {
* Return all of the stacks in the specified board.
*/
public function index() {
$boardError = $this->apiHelper->entityHasError( $this->request->params['boardId'], 'board', $this->boardService );
$boardError = $this->apiHelper->entityHasError($this->request->params['boardId'], 'board', $this->boardService);
if ($boardError) {
return new DataResponse($boardError['message'], $boardError['status']);
@@ -81,8 +81,29 @@ class StackApiController extends ApiController {
return new DataResponse($stacks, HTTP::STATUS_OK);
}
/**
* @NoAdminRequired
* @CORS
* @NoCSRFRequired
*
* Return all of the stacks in the specified board.
*/
public function get() {
$boardError = $this->apiHelper->entityHasError($this->request->params['boardId'], 'board', $this->boardService);
if ($boardError) {
return new DataResponse($boardError['message'], $boardError['status']);
}
$stack = $this->service->find($this->request->params['stackId']);
if ($stack == false || $stack == null) {
return new DataResponse("Stack not found", HTTP::STATUS_NOT_FOUND);
}
return new DataResponse($stack, HTTP::STATUS_OK);
}
/**
* @NoAdminRequired
* @CORS

View File

@@ -89,9 +89,19 @@ class StackService {
}
}
//TODO: Write this function so we can look up one stack id.
public function find($stackId) {
throw new \Exception('Not yet implemented');
$stack = $this->stackMapper->find($stackId);
$cards = $this->cardMapper->findAll($stackId);
foreach ($cards as $cardIndex => $card) {
$assignedUsers = $this->assignedUsersMapper->find($card->getId());
$card->setAssignedUsers($assignedUsers);
if (array_key_exists($card->id, $labels)) {
$cards[$cardIndex]->setLabels($labels[$card->id]);
}
$card->setAttachmentCount($this->attachmentService->count($card->getId()));
}
$stack->setCards($cards);
return $stack;
}
public function findAll($boardId) {