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)

View File

@ -62,7 +62,7 @@
<ul class="record_actions">
<li>
{% if person is not null %}
<a href="{{ path('chill_task_singletask_list', {'personId': person.id}) }}" class="sc-button bt-cancel">
<a href="{{ path('chill_task_singletask_list', {'person_id': person.id}) }}" class="sc-button bt-cancel">
{{ 'Back to the list' | trans }}
</a>
{% endif %}
@ -89,7 +89,7 @@
<ul class="record_actions">
<li>
{% if person is not null %}
<a href="{{ path('chill_task_singletask_list', {'personId': person.id, 'status' : [ status ] }) }}" class="sc-button bt-cancel">
<a href="{{ path('chill_task_singletask_list', {'person_id': person.id, 'status' : [ status ] }) }}" class="sc-button bt-cancel">
{{ 'See more' | trans }}
</a>
{% endif %}
@ -110,40 +110,57 @@
<h1>{{ 'Task list'|trans }}</h1>
{% if tasks_count == 0 %}
<p class="chill-no-data-statement">{{ "There is no tasks."|trans }}</p>
{% if person is not null %}
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
<!-- Pour l'instant, il n'est pas encore possible d'ajouter une tache sans personne liée -->
<!-- {% if person is null %}
<a href="{{ path('chill_task_single_task_new') }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %} -->
{% else %}
{% if single_task_ended_tasks is defined %}
{{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }}
{% endif %}
{% if single_task_ended_tasks is defined %}
{{ helper.date_status('Tasks with expired deadline', single_task_ended_tasks, single_task_ended_count, single_task_ended_paginator, 'ended', isSingleStatus, person) }}
{% endif %}
{% if single_task_warning_tasks is defined %}
{{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }}
{% endif %}
{% if single_task_warning_tasks is defined %}
{{ helper.date_status('Tasks with warning deadline reached', single_task_warning_tasks, single_task_warning_count, single_task_warning_paginator, 'warning', isSingleStatus, person) }}
{% endif %}
{% if single_task_current_tasks is defined %}
{{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }}
{% endif %}
{% if single_task_current_tasks is defined %}
{{ helper.date_status('Current tasks', single_task_current_tasks, single_task_current_count, single_task_current_paginator, 'current', isSingleStatus, person) }}
{% endif %}
{% if single_task_not_started_tasks is defined %}
{{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }}
{% endif %}
{% if single_task_not_started_tasks is defined %}
{{ helper.date_status('Tasks not started', single_task_not_started_tasks, single_task_not_started_count, single_task_not_started_paginator, 'not_started', isSingleStatus, person) }}
{% endif %}
{% if single_task_closed_tasks is defined %}
{{ helper.date_status('Closed', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }}
{% endif %}
{% if single_task_closed_tasks is defined %}
{{ helper.date_status('Closed', single_task_closed_tasks, single_task_closed_count, single_task_closed_paginator, 'closed', isSingleStatus, person) }}
{% endif %}
{% if isSingleStatus == false %}
<ul class="record_actions">
<li>
{% if person is not null %}
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
<!-- Pour l'instant, il n'est pas encore possible d'ajouter une tache sans personne liée -->
<!-- {% if person is null %}
<a href="{{ path('chill_task_single_task_new') }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %} -->
</li>
</ul>
{% endif %}
{% if isSingleStatus == false %}
<ul class="record_actions">
<li>
{% if person is not null %}
<a href="{{ path('chill_task_single_task_new', {'person_id': person.id}) }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
{% if user is not null %}
<a href="{{ path('chill_task_single_task_new') }}" class="sc-button bt-create">
{{ 'Add a new task' | trans }}
</a>
{% endif %}
</li>
</ul>
{% endif %}

View File

@ -32,11 +32,11 @@
{# filter tasks #}
{% if person is not null and user is null %}
{% if person is not null %}
{% block personcontent %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}
{% endblock %}
{% elseif user is not null and person is null %}
{% else %}
{% block content %}
{% include 'ChillTaskBundle:SingleTask:_list.html.twig' %}
{% endblock %}