From aebb21935b5f58dd030596362463bd741fd3550c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 16 Feb 2022 19:57:35 +0100 Subject: [PATCH] fix page "my accompanying period" and do not show drafts periods in homepage (+ ordering) --- .../Controller/UserAccompanyingPeriodController.php | 6 +++--- .../Repository/AccompanyingPeriodRepository.php | 3 ++- .../views/AccompanyingPeriod/user_periods_list.html.twig | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php index 51c8a32c0..321f212d5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/UserAccompanyingPeriodController.php @@ -30,7 +30,7 @@ class UserAccompanyingPeriodController extends AbstractController } /** - * @Route("/{_locale}/accompanying-periods", name="chill_person_accompanying_period_user") + * @Route("/{_locale}/person/accompanying-periods/my", name="chill_person_accompanying_period_user") */ public function listAction(Request $request) { @@ -44,13 +44,13 @@ class UserAccompanyingPeriodController extends AbstractController ); return $this->render('@ChillPerson/AccompanyingPeriod/user_periods_list.html.twig', [ - 'accompanyingds' => $accompanyingPeriods, + 'accompanyingPeriods' => $accompanyingPeriods, 'pagination' => $pagination, ]); } /** - * @Route("/{_locale}/accompanying-periods/drafts", name="chill_person_accompanying_period_draft_user") + * @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user") */ public function listDraftsAction(Request $request) { diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index 10b424cef..122b658bd 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -71,7 +71,7 @@ final class AccompanyingPeriodRepository implements ObjectRepository $qb = $this->buildQueryByRecentUserHistory($user, $since); return $qb->select('a') - ->distinct(true) + ->addOrderBy('userHistory.startDate', 'DESC') ->getQuery() ->setMaxResults($limit) ->setFirstResult($offset) @@ -95,6 +95,7 @@ final class AccompanyingPeriodRepository implements ObjectRepository $qb ->join('a.userHistories', 'userHistory') ->where($qb->expr()->eq('a.user', ':user')) + ->andWhere($qb->expr()->neq('a.step', "'" . AccompanyingPeriod::STEP_DRAFT . "'")) ->andWhere($qb->expr()->gte('userHistory.startDate', ':since')) ->andWhere($qb->expr()->isNull('userHistory.endDate')) ->setParameter('user', $user) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig index d30997bac..7395fceda 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/user_periods_list.html.twig @@ -20,6 +20,8 @@
{% for period in accompanyingPeriods %} {% include '@ChillPerson/AccompanyingPeriod/_list_item.html.twig' with {'period': period, 'recordAction': _self.recordAction(period)} %} + {% else %} +

{{ 'Any accompanying period'|trans }}

{% endfor %}