/** * Update column * * Change a column properties (wip_limit for now) * * <pre> * /!\ Kanban REST routes are under construction and subject to changes /!\ * </pre> * * @url PATCH {id} * * @param int $id Id of the column * @param int $kanban_id Id of the Kanban {@from query} * @param int $wip_limit The new wip limit {@from body} {@type int} */ protected function patch($id, $kanban_id, $wip_limit) { $current_user = $this->getCurrentUser(); $kanban = $this->getKanban($current_user, $kanban_id); try { $column = $this->kanban_column_factory->getColumnForAKanban($kanban, $id, $current_user); if (!$this->kanban_column_manager->setColumnWipLimit($current_user, $kanban, $column, $wip_limit)) { throw new RestException(500); } } catch (AgileDashboard_KanbanColumnNotFoundException $exception) { throw new RestException(404, $exception->getMessage()); } catch (AgileDashboard_UserNotAdminException $exception) { throw new RestException(401, $exception->getMessage()); } catch (AgileDashboard_SemanticStatusNotFoundException $exception) { throw new RestException(404, $exception->getMessage()); } }
/** * Add a new column * * Create a new kanban column. Will add another open value to the field corresponding to * the 'Status' semantic. An error will be thrown if the semantic 'Status' is not bound to * static values. * * @url POST {id}/columns * * @param string $id Id of the Kanban * @param KanbanColumnPOSTRepresentation $column The created kanban column {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnPOSTRepresentation} * * @throws 400 * @throws 401 * @throws 403 * @throws 404 * * @status 201 * * @return Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnRepresentation */ protected function postColumns($id, KanbanColumnPOSTRepresentation $column) { $current_user = $this->getCurrentUser(); $kanban_id = $id; $kanban = $this->getKanban($current_user, $kanban_id); $column_label = $column->label; try { $new_column_id = $this->kanban_column_manager->createColumn($current_user, $kanban, $column_label); } catch (AgileDashboard_UserNotAdminException $exception) { throw new RestException(401, $exception->getMessage()); } catch (Kanban_SemanticStatusNotDefinedException $exception) { throw new RestException(404, $exception->getMessage()); } catch (Kanban_SemanticStatusNotBoundToStaticValuesException $exception) { throw new RestException(400, $exception->getMessage()); } catch (Kanban_SemanticStatusBasedOnASharedFieldException $exception) { throw new RestException(400, $exception->getMessage()); } $this->form_element_factory->clearCaches(); $new_column = $this->kanban_column_factory->getColumnForAKanban($kanban, $new_column_id, $current_user); try { $this->kanban_actions_checker->checkUserCanAddInPlace($current_user, $kanban); $add_in_place = true; } catch (Exception $exception) { $add_in_place = false; } try { $this->kanban_actions_checker->checkUserCanDeleteColumn($current_user, $kanban, $new_column); $user_can_remove_column = true; } catch (Exception $exception) { $user_can_remove_column = false; } try { $this->kanban_actions_checker->checkUserCanEditColumnLabel($current_user, $kanban); $user_can_edit_label = true; } catch (Exception $exception) { $user_can_edit_label = false; } $column_representation = new KanbanColumnRepresentation(); $column_representation->build($new_column, $add_in_place, $user_can_remove_column, $user_can_edit_label); return $column_representation; }
/** * Add a new column * * Create a new kanban column. Will add another open value to the field corresponding to * the 'Status' semantic. An error will be thrown if the semantic 'Status' is not bound to * static values. * * @url POST {id}/columns * * @param string $id Id of the Kanban * @param KanbanColumnPOSTRepresentation $column The created kanban column {@from body} {@type Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnPOSTRepresentation} * * @throws 400 * @throws 401 * @throws 403 * @throws 404 * * @status 201 * * @return Tuleap\AgileDashboard\REST\v1\Kanban\KanbanColumnRepresentation */ protected function postColumns($id, KanbanColumnPOSTRepresentation $column) { $current_user = $this->getCurrentUser(); $kanban_id = $id; $kanban = $this->getKanban($current_user, $kanban_id); $column_label = $column->label; try { $new_column_id = $this->kanban_column_manager->createColumn($current_user, $kanban, $column_label); } catch (AgileDashboard_UserNotAdminException $exception) { throw new RestException(401, $exception->getMessage()); } catch (Kanban_SemanticStatus_Not_DefinedException $exception) { throw new RestException(404, $exception->getMessage()); } catch (Kanban_SemanticStatus_Not_Bound_To_Static_ValuesException $exception) { throw new RestException(400, $exception->getMessage()); } $this->form_element_factory->clearCaches(); $new_column = $this->kanban_column_factory->getColumnForAKanban($kanban, $new_column_id, $current_user); $add_in_place = $this->add_in_place_checker->canUserAddInPlace($current_user, $kanban); $column_representation = new KanbanColumnRepresentation(); $column_representation->build($new_column, $add_in_place); return $column_representation; }