translation and redirection

This commit is contained in:
Julien Fastré 2018-07-06 14:02:40 +02:00
parent 39e166eb5b
commit 5ada6d913c
4 changed files with 32 additions and 9 deletions

View File

@ -318,11 +318,12 @@ class SingleTaskController extends Controller
* options={ "menus": { "user": { "order": -10, "label": "My tasks", "icon": "tasks" } } } * options={ "menus": { "user": { "order": -10, "label": "My tasks", "icon": "tasks" } } }
* ) * )
*/ */
public function myTasksAction() public function myTasksAction(TranslatorInterface $translator)
{ {
return $this->redirectToRoute('chill_task_singletask_list', [ return $this->redirectToRoute('chill_task_singletask_list', [
'user_id' => $this->getUser()->getId(), 'user_id' => $this->getUser()->getId(),
'hide_form' => true 'hide_form' => true,
'title' => $translator->trans('My tasks')
]); ]);
} }

View File

@ -72,15 +72,29 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
$warning = $this->counter->countNotificationWarning($user); $warning = $this->counter->countNotificationWarning($user);
if ($ended > 0) { if ($ended > 0) {
$this->addItemInMenu($menu, $user, '%number% tasks over deadline', $ended, -15); $this->addItemInMenu(
$menu,
$user,
'%number% tasks over deadline',
'My tasks over deadline',
SingleTaskRepository::DATE_STATUS_ENDED,
$ended,
-15);
} }
if ($warning > 0) { if ($warning > 0) {
$this->addItemInMenu($menu, $user, '%number% tasks near deadline', $warning, -14); $this->addItemInMenu(
$menu,
$user,
'%number% tasks near deadline',
'My tasks near deadline',
SingleTaskRepository::DATE_STATUS_WARNING,
$warning,
-14);
} }
} }
protected function addItemInMenu(MenuItem $menu, User $u, $message, $number, $order) protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order)
{ {
if ($number > 0) { if ($number > 0) {
$menu->addChild( $menu->addChild(
@ -90,10 +104,10 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
'routeParameters' => [ 'routeParameters' => [
'user_id' => $u->getId(), 'user_id' => $u->getId(),
'status' => [ 'status' => [
SingleTaskRepository::DATE_STATUS_WARNING, $status
SingleTaskRepository::DATE_STATUS_ENDED
], ],
'hide_form' => true 'hide_form' => true,
'title' => $this->translator->trans($title)
] ]
]) ])
->setExtras([ ->setExtras([

View File

@ -81,5 +81,11 @@ cancel: annuler
'The task has been updated': 'La tâche a été mise à jour' 'The task has been updated': 'La tâche a été mise à jour'
'The transition is successfully applied': 'La transition a bien été effectuée' 'The transition is successfully applied': 'La transition a bien été effectuée'
'The transition could not be applied': "La transition n'a pas pu être appliquée" 'The transition could not be applied': "La transition n'a pas pu être appliquée"
#widget
'%number% tasks over deadline': '{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassée' '%number% tasks over deadline': '{0} Aucune tâche dépassée|{1} Une tâche dépassée | ]1,Inf[ %count% tâches dépassée'
'%number% tasks near deadline': '{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel' '%number% tasks near deadline': '{0} Aucune tâche en rappel|{1} Une tâche en rappel | ]1,Inf[ %count% tâches en rappel'
#title
My tasks near deadline: Mes tâches à échéance proche
My tasks over deadline: Mes tâches à échéance dépassée

View File

@ -141,7 +141,7 @@
{% import _self as helper %} {% import _self as helper %}
<h1>{{ app.request.title|default('Task list')|trans }}</h1> <h1>{{ app.request.query.get('title', null)|default('Task list'|trans) }}</h1>
{% if false == app.request.query.boolean('hide_form', false) %} {% if false == app.request.query.boolean('hide_form', false) %}
<h2>{{ 'Filter the tasks'|trans }}</h2> <h2>{{ 'Filter the tasks'|trans }}</h2>
@ -181,7 +181,9 @@
{% endif %} {% endif %}
{% else %} {% else %}
{% if false == app.request.query.boolean('hide_form', false) %}
<h2>{{ 'Tasks'|trans }}</h2> <h2>{{ 'Tasks'|trans }}</h2>
{% endif %}
{% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %} {% if person is not null and is_granted('CHILL_TASK_TASK_CREATE', person) %}
<ul class="record_actions"> <ul class="record_actions">