From 35d807cab0d1ebc14c6b36dd7f7c366b4689d355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 5 Nov 2021 12:31:41 +0000 Subject: [PATCH] Bugfixes/tasks list --- CHANGELOG.md | 1 + .../Security/ParentRoleHelper.php | 4 ++- .../Templating/Listing/FilterOrderHelper.php | 2 +- .../Authorization/ParentRoleHelperTest.php | 3 +- .../Entity/Household/HouseholdMember.php | 6 ++++ .../Controller/SingleTaskController.php | 4 +-- .../ChillTaskBundle/Menu/UserMenuBuilder.php | 34 +++++++++---------- .../SingleTaskAclAwareRepository.php | 4 +-- .../AccompanyingCourse/list.html.twig | 4 ++- .../views/SingleTask/List/index.html.twig | 4 ++- .../SingleTask/List/index_my_tasks.html.twig | 34 +++++++++++++++++++ 11 files changed, 74 insertions(+), 26 deletions(-) create mode 100644 src/Bundle/ChillTaskBundle/Resources/views/SingleTask/List/index_my_tasks.html.twig diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c7821987..691a1b945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to * refactor `AuthorizationHelper` and `UserACLAwareRepository` to fix constructor, and separate logic for parent role helper into `ParentRoleHelper` * [main]: filter location and locationType in backend: exclude NULL names, only active and availableToUsers * [activity]: perform client-side validation & show/hide fields in the "new location" modal +* [tasks]: different layout for task list / my tasks, and fix link to tasks in alert or in warning * [admin]: links to activity admin section added again. diff --git a/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php b/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php index 07366dafa..0d0fd0b94 100644 --- a/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php +++ b/src/Bundle/ChillMainBundle/Security/ParentRoleHelper.php @@ -33,12 +33,14 @@ class ParentRoleHelper * Return all the role which give access to the given role. Only the role * which are registered into Chill are taken into account. * + * The array contains always the current $role (which give access to himself) + * * @param string $role * @return string[] the role which give access to the given $role */ public function getParentRoles(string $role): array { - $parentRoles = []; + $parentRoles = [$role]; // transform the roles from role hierarchy from string to Role $roles = \array_keys($this->hierarchy); diff --git a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php index 0a28d39ca..8f349da4b 100644 --- a/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php @@ -14,7 +14,7 @@ class FilterOrderHelper private ?array $searchBoxFields = null; private array $checkboxes = []; private ?array $submitted = null; - private ?string $formName = 'filter'; + private ?string $formName = 'f'; private string $formType = FilterOrderType::class; private array $formOptions = []; diff --git a/src/Bundle/ChillMainBundle/Tests/Authorization/ParentRoleHelperTest.php b/src/Bundle/ChillMainBundle/Tests/Authorization/ParentRoleHelperTest.php index 0d718ec09..5f98879b4 100644 --- a/src/Bundle/ChillMainBundle/Tests/Authorization/ParentRoleHelperTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Authorization/ParentRoleHelperTest.php @@ -23,9 +23,10 @@ class ParentRoleHelperTest extends KernelTestCase $parentRoles = $this->parentRoleHelper->getParentRoles(PersonVoter::SEE); - $this->assertCount(2, $parentRoles); + $this->assertCount(3, $parentRoles); $this->assertContains(PersonVoter::CREATE, $parentRoles); $this->assertContains(PersonVoter::UPDATE, $parentRoles); + $this->assertContains(PersonVoter::SEE, $parentRoles); } public function testIsRoleReached() diff --git a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php index 89ec4feb5..d157aa58a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php +++ b/src/Bundle/ChillPersonBundle/Entity/Household/HouseholdMember.php @@ -159,6 +159,12 @@ class HouseholdMember return $this->shareHousehold; } + public function setShareHousehold(bool $shareHousehold): self + { + $this->shareHousehold = $shareHousehold; + + return $this; + } public function getPerson(): ?Person { diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 141ca049d..d8944ae93 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -452,7 +452,7 @@ final class SingleTaskController extends AbstractController * @return Response * @Route( * "/{_locale}/task/single-task/list/my", - * name="chill_task_single_my_tasks" + * name="chill_task_singletask_my_tasks" * ) */ public function myTasksAction() @@ -480,7 +480,7 @@ final class SingleTaskController extends AbstractController ] ); - return $this->render('@ChillTask/SingleTask/List/index.html.twig', [ + return $this->render('@ChillTask/SingleTask/List/index_my_tasks.html.twig', [ 'tasks' => $tasks, 'paginator' => $paginator, 'filter_order' => $filterOrder, diff --git a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php index e5841c849..419dab9b3 100644 --- a/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php +++ b/src/Bundle/ChillTaskBundle/Menu/UserMenuBuilder.php @@ -88,27 +88,27 @@ class UserMenuBuilder implements LocalMenuBuilderInterface if ($ended > 0) { $this->addItemInMenu( $menu, - $user, '%number% tasks over deadline', - 'My tasks over deadline', - SingleTaskRepository::DATE_STATUS_ENDED, $ended, - -15); + -15, + ['new', 'in_progress'], + ['alert'] + ); } if ($warning > 0) { $this->addItemInMenu( $menu, - $user, '%number% tasks near deadline', - 'My tasks near deadline', - SingleTaskRepository::DATE_STATUS_WARNING, $warning, - -14); + -14, + ['new', 'in_progress'], + ['warning'] + ); } $menu->addChild("My tasks", [ - 'route' => 'chill_task_single_my_tasks' + 'route' => 'chill_task_singletask_my_tasks' ]) ->setExtras([ 'order' => -10, @@ -117,20 +117,20 @@ class UserMenuBuilder implements LocalMenuBuilderInterface } - protected function addItemInMenu(MenuItem $menu, User $u, $message, $title, $status, $number, $order) + protected function addItemInMenu(MenuItem $menu, $message, $number, $order, array $states = [], array $status = []) { if ($number > 0) { $menu->addChild( $this->translator->transChoice($message, $number), [ - 'route' => 'chill_task_singletask_list', + 'route' => 'chill_task_singletask_my_tasks', 'routeParameters' => [ - 'user_id' => $u->getId(), - 'status' => [ - $status - ], - 'hide_form' => true, - 'title' => $this->translator->trans($title) + 'f' => [ + 'checkboxes' => [ + 'states' => $states, + 'status' => $status + ] + ] ] ]) ->setExtras([ diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php index c728096cb..be8833e75 100644 --- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php +++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskAclAwareRepository.php @@ -284,8 +284,8 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository $qb->expr()->andX( $qb->expr()->not($qb->expr()->isNull('t.endDate')), $qb->expr()->not($qb->expr()->isNull('t.warningInterval')), - $qb->expr()->gte('t.endDate - t.warningInterval', ':now'), - $qb->expr()->lt('t.endDate', ':now') + $qb->expr()->lte('t.endDate - t.warningInterval', ':now'), + $qb->expr()->gt('t.endDate', ':now') ) ); $qb diff --git a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig index 6622bca4f..d00ee7a5e 100644 --- a/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig +++ b/src/Bundle/ChillTaskBundle/Resources/views/SingleTask/AccompanyingCourse/list.html.twig @@ -21,7 +21,7 @@ {{ chill_pagination(paginator) }} - {% if is_granted('CHILL_TASK_TASK_CREATE_FOR_COURSE', person) %} + {% if is_granted('CHILL_TASK_TASK_CREATE_FOR_COURSE', accompanyingCourse) %}