Merge remote-tracking branch 'origin/master'

This commit is contained in:
2018-05-03 23:40:17 +02:00
7 changed files with 162 additions and 29 deletions

View File

@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Chill\TaskBundle\Entity\SingleTask;
use Chill\TaskBundle\Form\SingleTaskType;
use Chill\TaskBundle\Form\SingleTaskListType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormFactoryInterface;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
@@ -433,7 +434,68 @@ class SingleTaskController extends Controller
$viewParams['layout'] = 'ChillMainBundle::layout.html.twig';
}
return $this->render('ChillTaskBundle:SingleTask:index.html.twig', $viewParams);
// Form for filtering tasks
$form = $this->createForm(SingleTaskListType::class, null, [
//'center' => $task->getCenter()
]);
$form->add('submit', SubmitType::class);
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->isValid()) {
$formData = $form->getData();
$status = $statuses[$formData['status']];
$viewParamsForm['user'] = $formData['user'];
$viewParamsForm['isSingleStatus'] = $singleStatus = count($statuses) === 1;
// herit some parameters from the page
$viewParamsForm['person'] = $viewParams['person'];
$viewParamsForm['layout'] = $viewParams['layout'];
// 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, $formData['user'])
;
$paginator = $paginatorFactory->create($count);
$viewParamsForm['single_task_'.$status.'_count'] = $count;
$viewParamsForm['single_task_'.$status.'_paginator'] = $paginator;
$viewParamsForm['single_task_'.$status.'_tasks'] = $taskRepository
->findByParameters($params, $formData['user'],
$singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0,
$singleStatus ? $paginator->getItemsPerPage() : 10)
;
// total number of tasks
$viewParamsForm['tasks_count'] = $count;
return $this->render('ChillTaskBundle:SingleTask:index.html.twig', array(
'view' => $viewParamsForm,
'form' => $form->createView()
));
} else {
$this->addFlash('error', "wrong test");
}
}
dump($viewParams);
return $this->render('ChillTaskBundle:SingleTask:index.html.twig', array(
'view' => $viewParams,
'form' => $form->createView()
));
}

View File

@@ -71,10 +71,10 @@ class TaskController extends Controller
$em->flush();
$this->addFlash('success', 'The transition is sucessfully appliyed');
$this->addFlash('success', 'The transition is successfully applied');
} else {
$this->addFlash('error', 'The transition could not be appliyed');
$this->addFlash('error', 'The transition could not be applied');
}
return $this->redirect($request->query->get('return_path', $defaultReturnPath));