add message when there is no task + improve when request with multiple input (user, scope and person)

This commit is contained in:
nobohan
2018-04-27 10:16:30 +02:00
parent bf0db0de3f
commit fd2bee979a
3 changed files with 67 additions and 41 deletions

View File

@@ -32,6 +32,7 @@ class SingleTaskController extends Controller
*/
public function newAction(Request $request)
{
$personId = $request->query->getInt('person_id', null);
if ($personId === null) {
@@ -47,8 +48,8 @@ class SingleTaskController extends Controller
}
$task = (new SingleTask())
->setPerson($person)
->setAssignee($this->getUser())
->setPerson($person)
->setType('task_default')
;
@@ -69,7 +70,7 @@ class SingleTaskController extends Controller
$this->addFlash('success', "The task is created");
return $this->redirectToRoute('chill_task_task_list_by_person', [
'personId' => $task->getPerson()->getId()
'person_id' => $task->getPerson()->getId()
]);
} else {
@@ -173,7 +174,7 @@ class SingleTaskController extends Controller
$this->addFlash('success', "Success : task updated!");
return $this->redirectToRoute('chill_task_task_list_by_person', [
'personId' => $task->getPerson()->getId()
'person_id' => $task->getPerson()->getId()
]);
} else {
@@ -253,7 +254,7 @@ class SingleTaskController extends Controller
return $this->redirect($this->generateUrl(
'chill_task_task_list_by_person', array(
'personId' => $personId
'person_id' => $personId
)));
}
}
@@ -308,7 +309,7 @@ class SingleTaskController extends Controller
// Get parameters from url
if ($request->query->has('person_id')) {
$personId = $request->query->get('person_id');
$personId = $request->query->getInt('person_id', null);
$person = $personRepository->find($personId);
if ($person === null) {
@@ -323,7 +324,7 @@ class SingleTaskController extends Controller
if ($request->query->has('user_id')) {
$userId = $request->query->get('user_id');
$userId = $request->query->getInt('user_id', null);
$user = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:User')
->find($userId);
@@ -338,7 +339,7 @@ class SingleTaskController extends Controller
if ($request->query->has('scope_id')) {
$scopeId = $request->query->get('scope_id');
$scopeId = $request->query->getInt('scope_id', null);
$scope = $this->getDoctrine()->getManager()
->getRepository('ChillMainBundle:Scope')
->find($scopeId);
@@ -366,6 +367,8 @@ class SingleTaskController extends Controller
$viewParams['isSingleStatus'] = $singleStatus = count($statuses) === 1;
$tasks_count = 0;
foreach($statuses as $status) {
if($request->query->has('status')
&& FALSE === \in_array($status, $statuses)) {
@@ -393,8 +396,13 @@ class SingleTaskController extends Controller
$singleStatus ? $paginator->getCurrentPage()->getFirstItemNumber() : 0,
$singleStatus ? $paginator->getItemsPerPage() : 10)
;
$tasks_count = $tasks_count + $count;
}
// total number of tasks
$viewParams['tasks_count'] = $tasks_count;
if ($request->query->has('person_id')){
$viewParams['layout'] = 'ChillPersonBundle::layout.html.twig';
} else {
@@ -404,6 +412,7 @@ class SingleTaskController extends Controller
return $this->render('ChillTaskBundle:SingleTask:index.html.twig', $viewParams);
}
protected function getPersonParam(Request $request, EntityManagerInterface $em)
{
$person = $em->getRepository(Person::class)