From c36778184d58d545f1d95e44ee40335a9d92f11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 18 Oct 2018 19:59:11 +0200 Subject: [PATCH 1/4] fix bug in listing users in form filtering tasks --- CHANGELOG.md | 5 +++++ Form/SingleTaskListType.php | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..bc10c555c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +Branch master +============= + +- fix bug in filter task form: allow to show the list of users, which was hidden when the user had access to multiple centers; + diff --git a/Form/SingleTaskListType.php b/Form/SingleTaskListType.php index f6b47e409..0cd4eba6b 100644 --- a/Form/SingleTaskListType.php +++ b/Form/SingleTaskListType.php @@ -237,10 +237,11 @@ class SingleTaskListType extends AbstractType } $i = 0; + $circleCenterCond = $qb->expr()->orX(); foreach ($centers as $center) { $circles = $this->authorizationHelper->getReachableCircles($user, $role, $center); // add condition about person and circle - $qb->andWhere( + $circleCenterCond->add( $qb->expr()->andX() ->add($qb->expr()->eq('person.center', ':center_'.$i)) ->add($qb->expr()->in('task.circle', ':circles_'.$i)) @@ -252,6 +253,7 @@ class SingleTaskListType extends AbstractType // increase counter $i++; } + $qb->andWhere($circleCenterCond); return $qb->getQuery()->getResult(); } From 7c113e3478e038b639f38edf46acb8b02c882109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 18 Oct 2018 20:05:02 +0200 Subject: [PATCH 2/4] add assignee in task list + fix some translation --- CHANGELOG.md | 2 ++ Resources/translations/messages.fr.yml | 2 +- Resources/views/SingleTask/_list.html.twig | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc10c555c..77986b1fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,4 +2,6 @@ Branch master ============= - fix bug in filter task form: allow to show the list of users, which was hidden when the user had access to multiple centers; +- add assignee in task list; +- fix some translation; diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index bea9f527e..04d7d2dbe 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -59,7 +59,7 @@ Any user: Tous les utilisateurs Unassigned: Non assigné Associated person: Personne associée Default task: Tâche par défaut - +Not assigned: Aucun utilisateur assigné # transitions - default task definition 'new': 'nouvelle' diff --git a/Resources/views/SingleTask/_list.html.twig b/Resources/views/SingleTask/_list.html.twig index 0f465e17b..341fbcc8a 100644 --- a/Resources/views/SingleTask/_list.html.twig +++ b/Resources/views/SingleTask/_list.html.twig @@ -26,6 +26,14 @@ {% for place in workflow_marked_places(task) %} {{ place|trans }} {% endfor %} + + {% if task.assignee is not null %} +
+
{{ 'Assignee'|trans }}
+
{{ task.assignee.username }}
+
+ {% endif %} + {% if task.startDate is null and task.warningDate is null and task.endDate is null %} From fe5f63457b06d694e5d123914a1fcf10c4a15df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 18 Oct 2018 20:51:49 +0200 Subject: [PATCH 3/4] add a filtering of tasks by center --- CHANGELOG.md | 1 + Controller/SingleTaskController.php | 11 ++++++++++- Form/SingleTaskListType.php | 20 ++++++++++++++++++++ Repository/SingleTaskRepository.php | 11 ++++++++++- Resources/translations/messages.fr.yml | 2 ++ Resources/views/SingleTask/_list.html.twig | 4 ++++ 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77986b1fa..5505240e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,4 +4,5 @@ Branch master - fix bug in filter task form: allow to show the list of users, which was hidden when the user had access to multiple centers; - add assignee in task list; - fix some translation; +- add a filtering by center on list; diff --git a/Controller/SingleTaskController.php b/Controller/SingleTaskController.php index 89540d22e..25b59c16f 100644 --- a/Controller/SingleTaskController.php +++ b/Controller/SingleTaskController.php @@ -25,6 +25,7 @@ use Chill\TaskBundle\Event\TaskEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Translation\TranslatorInterface; use Chill\TaskBundle\Event\UI\UIEvent; +use Chill\MainBundle\Repository\CenterRepository; class SingleTaskController extends Controller @@ -360,6 +361,7 @@ class SingleTaskController extends Controller PaginatorFactory $paginatorFactory, SingleTaskRepository $taskRepository, PersonRepository $personRepository, + CenterRepository $centerRepository, FormFactoryInterface $formFactory ) { /* @var $viewParams array The parameters for the view */ @@ -370,7 +372,6 @@ class SingleTaskController extends Controller $viewParams['user'] = null; $params['user'] = null; $viewParams['center'] = null; - $params['center'] = null; $params['types'] = null; // Get parameters from url @@ -386,6 +387,14 @@ class SingleTaskController extends Controller $viewParams['person'] = $person; $params['person'] = $person; + } elseif (!empty($request->query->get('center_id', NULL))) { + $center = $centerRepository->find($request->query->getInt('center_id')); + dump($center); + if ($center === null) { + throw $this->createNotFoundException('center not found'); + } + + $params['center'] = $center; } if(!empty($request->query->get('types', []))) { diff --git a/Form/SingleTaskListType.php b/Form/SingleTaskListType.php index 0cd4eba6b..99e8ddb42 100644 --- a/Form/SingleTaskListType.php +++ b/Form/SingleTaskListType.php @@ -136,6 +136,17 @@ class SingleTaskListType extends AbstractType 'label' => 'Associated person' ]) ; + $reachablesCenters = $this->getReachablesCenters(); + if (count($reachablesCenters) > 1) { + $builder + ->add('center_id', EntityType::class, [ + 'class' => \Chill\MainBundle\Entity\Center::class, + 'choices' => $reachablesCenters, + 'label' => 'Center', + 'required' => false, + 'placeholder' => 'All centers' + ]); + } } else { // add a hidden field $builder @@ -144,6 +155,7 @@ class SingleTaskListType extends AbstractType ->addModelTransformer(new PersonToIdTransformer($this->em)) ; } + } protected function getUserChoices($options) @@ -257,6 +269,14 @@ class SingleTaskListType extends AbstractType return $qb->getQuery()->getResult(); } + + protected function getReachablesCenters() + { + $user = $this->tokenStorage->getToken()->getUser(); + $role = new Role(TaskVoter::SHOW); + + return $this->authorizationHelper->getReachableCenters($user, $role); + } public function configureOptions(OptionsResolver $resolver) { diff --git a/Repository/SingleTaskRepository.php b/Repository/SingleTaskRepository.php index 92e04f1a8..606079663 100644 --- a/Repository/SingleTaskRepository.php +++ b/Repository/SingleTaskRepository.php @@ -8,6 +8,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Symfony\Component\Security\Core\Role\Role; use Chill\TaskBundle\Security\Authorization\TaskVoter; use Doctrine\DBAL\Types\Type; +use Chill\MainBundle\Entity\Center; /** * SingleTaskRepository @@ -107,6 +108,14 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository if (\array_key_exists('person', $params) and !empty($params['person'])) { $qb->andWhere($qb->expr()->eq('st.person', ':person')); $qb->setParameter('person', $params['person']); + } elseif (\array_key_exists('center', $params)) { + if ($params['center'] instanceof Center) { + $qb->join('st.person', 'person'); + $qb->andWhere($qb->expr()->eq('person.center', ':center')); + $qb->setParameter('center', $params['center']); + } else { + throw new \UnexpectedValueException("params 'center' should be an instance of ".Center::class); + } } if (\array_key_exists('unassigned', $params) and $params['unassigned'] === true) { @@ -142,7 +151,7 @@ class SingleTaskRepository extends \Doctrine\ORM\EntityRepository if (\array_key_exists('is_closed', $params)) { $qb->andWhere($this->buildIsClosed($qb, !$params['is_closed'])); } - + } protected function addTypeFilter(QueryBuilder $qb, $params) diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 04d7d2dbe..239ee16ab 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -99,3 +99,5 @@ My tasks over deadline: Mes tâches à échéance dépassée #transition page Apply transition on task %title%: Appliquer la transition sur la tâche %title% + +All centers: Tous les centres diff --git a/Resources/views/SingleTask/_list.html.twig b/Resources/views/SingleTask/_list.html.twig index 341fbcc8a..4af98d5b3 100644 --- a/Resources/views/SingleTask/_list.html.twig +++ b/Resources/views/SingleTask/_list.html.twig @@ -168,6 +168,10 @@ {{ form_row(form.person_id) }} {% endif %} + {% if form.center_id is defined %} + {{ form_row(form.center_id) }} + {% endif %} +
  • From fe45ce5447cce5328e256c6db777191cbab65a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 18 Oct 2018 21:31:02 +0200 Subject: [PATCH 4/4] add color to task status --- CHANGELOG.md | 1 + Resources/public/sass/_task-statuses.scss | 34 ++++++++++++++++++++++ Resources/public/sass/_task.scss | 1 + Resources/views/SingleTask/_list.html.twig | 2 +- Resources/views/SingleTask/show.html.twig | 11 ++----- 5 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 Resources/public/sass/_task-statuses.scss diff --git a/CHANGELOG.md b/CHANGELOG.md index 5505240e4..899141238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,4 +5,5 @@ Branch master - add assignee in task list; - fix some translation; - add a filtering by center on list; +- add color in boxes for task statuses; diff --git a/Resources/public/sass/_task-statuses.scss b/Resources/public/sass/_task-statuses.scss new file mode 100644 index 000000000..5e371359e --- /dev/null +++ b/Resources/public/sass/_task-statuses.scss @@ -0,0 +1,34 @@ +.task-status { + &.box { + font-variant: small-caps; + display: inline; + padding: .2em .6em .3em; + font-size: 0.88rem; + font-weight: bold; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: .25em; + color: white; + } + + &.type-task_default { + // 'new', 'in_progress', 'closed', 'canceled' + &.place-new { + background-color: var(--chill-yellow); + } + + &.place-in_progress { + background-color: var(--chill-green); + } + + &.place-closed { + background-color: var(--chill-blue); + } + + &.place-canceled { + background-color: var(--chill-beige); + } + } +} diff --git a/Resources/public/sass/_task.scss b/Resources/public/sass/_task.scss index 308f9cbfd..6f28b5164 100644 --- a/Resources/public/sass/_task.scss +++ b/Resources/public/sass/_task.scss @@ -1,4 +1,5 @@ @import '../../../../main/Resources/public/sass/custom/config/colors'; +@import "_task-statuses.scss"; div#single_task_warningInterval { display: flex; diff --git a/Resources/views/SingleTask/_list.html.twig b/Resources/views/SingleTask/_list.html.twig index 4af98d5b3..3a2af26e0 100644 --- a/Resources/views/SingleTask/_list.html.twig +++ b/Resources/views/SingleTask/_list.html.twig @@ -24,7 +24,7 @@ {% endif %} {% for place in workflow_marked_places(task) %} - {{ place|trans }} + {{ place|trans }} {% endfor %} {% if task.assignee is not null %} diff --git a/Resources/views/SingleTask/show.html.twig b/Resources/views/SingleTask/show.html.twig index cc046b8db..7c35e010a 100644 --- a/Resources/views/SingleTask/show.html.twig +++ b/Resources/views/SingleTask/show.html.twig @@ -25,17 +25,12 @@ {% block personcontent %}

    {{ 'Task'|trans }}

    -

    {{ task.title }}

    +

    {{ task.title }} {% for place in workflow_marked_places(task) %} + {{ place|trans }} + {% endfor %}

    -
    {{ 'Task status'|trans }}
    -
    - {% for place in workflow_marked_places(task) %} - {{ place|trans }} - {% endfor %} -
    -
    {{ 'Description'|trans }}
    {% if task.description is empty %}