mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
add closed tasks
- the entity has a new column / property "closed" (boolean) - An event listener in created during container compilation, which listen on tasks status changed - The taskworkflow manager and task workflow definition indicate if the tasks is closed ; - Add list for closed tasks in controller, and change parameter 'date_status' to 'status'; - and change query to allow to filter on closed tasks
This commit is contained in:
@@ -298,39 +298,42 @@ class SingleTaskController extends Controller
|
||||
$viewParams['person'] = $person;
|
||||
// collect parameters for filter
|
||||
$params['person'] = $person;
|
||||
$statuses = $request->query->get('date_status', []);
|
||||
$possibleStatuses = \array_merge(SingleTaskRepository::DATE_STATUSES, [ 'closed' ]);
|
||||
$statuses = $request->query->get('status', $possibleStatuses);
|
||||
|
||||
if ($statuses) {
|
||||
// check for invalid parameters
|
||||
$diff = \array_diff(
|
||||
$statuses,
|
||||
SingleTaskRepository::DATE_STATUSES)
|
||||
;
|
||||
|
||||
if (count($diff) > 0) {
|
||||
return new Response(
|
||||
'date_status not allowed: '. \implode(', ', $diff),
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
// check for invalid statuses
|
||||
$diff = \array_diff($statuses, $possibleStatuses);
|
||||
if (count($diff) > 0) {
|
||||
return new Response(
|
||||
'date_status not allowed: '. \implode(', ', $diff),
|
||||
Response::HTTP_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
$viewParams['isSingleStatus'] = $singleStatus = count($statuses) === 1;
|
||||
|
||||
foreach(SingleTaskRepository::DATE_STATUSES as $type) {
|
||||
if($request->query->has('date_status')
|
||||
&& FALSE === \in_array($type, $statuses ?? [])) {
|
||||
foreach($statuses as $status) {
|
||||
if($request->query->has('status')
|
||||
&& FALSE === \in_array($status, $statuses)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$params['date_status'] = $type;
|
||||
// different query if regarding to date or 'closed'
|
||||
if (in_array($status, SingleTaskRepository::DATE_STATUSES)) {
|
||||
$params['date_status'] = $status;
|
||||
$params['is_closed'] = false;
|
||||
} else {
|
||||
$params['date_status'] = null;
|
||||
$params['is_closed'] = true;
|
||||
}
|
||||
|
||||
$count = $taskRepository
|
||||
->countByParameters($params, $this->getUser())
|
||||
;
|
||||
$paginator = $paginatorFactory->create($count);
|
||||
$viewParams['single_task_'.$type.'_count'] = $count;
|
||||
$viewParams['single_task_'.$type.'_paginator'] = $paginator;
|
||||
$viewParams['single_task_'.$type.'_tasks'] = $taskRepository
|
||||
$viewParams['single_task_'.$status.'_count'] = $count;
|
||||
$viewParams['single_task_'.$status.'_paginator'] = $paginator;
|
||||
$viewParams['single_task_'.$status.'_tasks'] = $taskRepository
|
||||
->findByParameters($params, $this->getUser(),
|
||||
$singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0,
|
||||
$singleStatus ? $paginator->getItemsPerPage() : 10)
|
||||
|
Reference in New Issue
Block a user