mirror of
https://github.com/Karaka-Management/oms-Kanban.git
synced 2026-02-16 20:28:42 +00:00
update draft
This commit is contained in:
parent
a8c6ff9acc
commit
44b005a8cd
|
|
@ -29,6 +29,8 @@ use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Model\Message\FormValidation;
|
use phpOMS\Model\Message\FormValidation;
|
||||||
|
use Modules\Kanban\Models\KanbanCardComment;
|
||||||
|
use Modules\Kanban\Models\KanbanCardCommentMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kanban controller class.
|
* Kanban controller class.
|
||||||
|
|
@ -66,7 +68,7 @@ final class ApiController extends Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$card = $this->createKanbanCardFromRquest($request);
|
$card = $this->createKanbanCardFromRequest($request);
|
||||||
$this->createModel($request->getHeader()->getAccount(), $card, KanbanCardMapper::class, 'card', $request->getOrigin());
|
$this->createModel($request->getHeader()->getAccount(), $card, KanbanCardMapper::class, 'card', $request->getOrigin());
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Card', 'Card successfully created.', $card);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Card', 'Card successfully created.', $card);
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +82,7 @@ final class ApiController extends Controller
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createKanbanCardFromRquest(RequestAbstract $request) : KanbanCard
|
public function createKanbanCardFromRequest(RequestAbstract $request) : KanbanCard
|
||||||
{
|
{
|
||||||
$card = new KanbanCard();
|
$card = new KanbanCard();
|
||||||
$card->setName((string) ($request->getData('title')));
|
$card->setName((string) ($request->getData('title')));
|
||||||
|
|
@ -124,6 +126,73 @@ final class ApiController extends Controller
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routing end-point for application behaviour.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param ResponseAbstract $response Response
|
||||||
|
* @param mixed $data Generic data
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function apiKanbanCardCommentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||||
|
{
|
||||||
|
if (!empty($val = $this->validateKanbanCardCommentCreate($request))) {
|
||||||
|
$response->set('kanban_comment_create', new FormValidation($val));
|
||||||
|
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$comment = $this->createKanbanCardCommentFromRequest($request);
|
||||||
|
$this->createModel($request->getHeader()->getAccount(), $comment, KanbanCardCommentMapper::class, 'comment', $request->getOrigin());
|
||||||
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Card', 'Card successfully created.', $comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create comment from request.
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return KanbanCardComment
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function createKanbanCardCommentFromRequest(RequestAbstract $request) : KanbanCardComment
|
||||||
|
{
|
||||||
|
$comment = new KanbanCardComment();
|
||||||
|
$comment->setDescription((string) ($request->getData('plain') ?? ''));
|
||||||
|
$comment->setCard((int) $request->getData('card'));
|
||||||
|
$comment->setCreatedBy(new NullAccount($request->getHeader()->getAccount()));
|
||||||
|
|
||||||
|
return $comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate comment create request
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
*
|
||||||
|
* @return array<string, bool>
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private function validateKanbanCardCommentCreate(RequestAbstract $request) : array
|
||||||
|
{
|
||||||
|
$val = [];
|
||||||
|
if (($val['plain'] = empty($request->getData('plain')))
|
||||||
|
|| ($val['card'] = empty($request->getData('card')))
|
||||||
|
) {
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing end-point for application behaviour.
|
* Routing end-point for application behaviour.
|
||||||
*
|
*
|
||||||
|
|
@ -146,7 +215,7 @@ final class ApiController extends Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$board = $this->createKanbanBoardFromRquest($request);
|
$board = $this->createKanbanBoardFromRequest($request);
|
||||||
$this->createModel($request->getHeader()->getAccount(), $board, KanbanBoardMapper::class, 'board',$request->getOrigin());
|
$this->createModel($request->getHeader()->getAccount(), $board, KanbanBoardMapper::class, 'board',$request->getOrigin());
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully created.', $board);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Board', 'Board successfully created.', $board);
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +229,7 @@ final class ApiController extends Controller
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createKanbanBoardFromRquest(RequestAbstract $request) : KanbanBoard
|
public function createKanbanBoardFromRequest(RequestAbstract $request) : KanbanBoard
|
||||||
{
|
{
|
||||||
$board = new KanbanBoard();
|
$board = new KanbanBoard();
|
||||||
$board->setName((string) $request->getData('title'));
|
$board->setName((string) $request->getData('title'));
|
||||||
|
|
@ -218,7 +287,7 @@ final class ApiController extends Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$column = $this->createKanbanColumnFromRquest($request);
|
$column = $this->createKanbanColumnFromRequest($request);
|
||||||
$this->createModel($request->getHeader()->getAccount(), $column, KanbanColumnMapper::class, 'column', $request->getOrigin());
|
$this->createModel($request->getHeader()->getAccount(), $column, KanbanColumnMapper::class, 'column', $request->getOrigin());
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Column', 'Column successfully created.', $column);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Column', 'Column successfully created.', $column);
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +301,7 @@ final class ApiController extends Controller
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function createKanbanColumnFromRquest(RequestAbstract $request) : KanbanColumn
|
public function createKanbanColumnFromRequest(RequestAbstract $request) : KanbanColumn
|
||||||
{
|
{
|
||||||
$column = new KanbanColumn();
|
$column = new KanbanColumn();
|
||||||
$column->setName((string) $request->getData('title'));
|
$column->setName((string) $request->getData('title'));
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,19 @@
|
||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.4
|
||||||
|
*
|
||||||
|
* @package Modules\Tasks
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use phpOMS\Uri\UriFactory;
|
||||||
|
|
||||||
$boards = $this->getData('boards');
|
$boards = $this->getData('boards');
|
||||||
|
|
||||||
echo $this->getData('nav')->render(); ?>
|
echo $this->getData('nav')->render(); ?>
|
||||||
|
|
@ -6,7 +21,7 @@ echo $this->getData('nav')->render(); ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<?php foreach ($boards as $board) : ?>
|
<?php foreach ($boards as $board) : ?>
|
||||||
<div class="col-xs-12 col-sm-6 col-lg-3">
|
<div class="col-xs-12 col-sm-6 col-lg-3">
|
||||||
<a href="<?= $this->printHtml(\phpOMS\Uri\UriFactory::build('{/prefix}kanban/board?{?}&id=' . $board->getId())); ?>">
|
<a href="<?= $this->printHtml(UriFactory::build('{/prefix}kanban/board?{?}&id=' . $board->getId())); ?>">
|
||||||
<section class="portlet">
|
<section class="portlet">
|
||||||
<div class="portlet-head"><?= $this->printHtml($board->getName()); ?></div>
|
<div class="portlet-head"><?= $this->printHtml($board->getName()); ?></div>
|
||||||
<div class="portlet-body">
|
<div class="portlet-body">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user