From bca0d04201f4002ca4bb08aa260a166aa519717d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 13 Jun 2024 18:01:35 +0200 Subject: [PATCH 1/2] Update calendar list display for the the next calendar in search results The calendar list display in ChillPersonBundle has been revamped, including a new view and style modifications. This update enables the display of calendars as a list for easy navigation with an added authorization check. Also, a new SCSS file named "calendar-list.scss" has been created and imported to enhance the UI/UX design. --- .../unreleased/Feature-20240613-180648.yaml | 9 +++++++ .../Resources/public/chill/chill.js | 1 + .../public/chill/scss/calendar-list.scss | 26 +++++++++++++++++++ .../views/Person/list_with_period.html.twig | 19 +++++++++++++- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Feature-20240613-180648.yaml create mode 100644 src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar-list.scss diff --git a/.changes/unreleased/Feature-20240613-180648.yaml b/.changes/unreleased/Feature-20240613-180648.yaml new file mode 100644 index 000000000..700d5bdd1 --- /dev/null +++ b/.changes/unreleased/Feature-20240613-180648.yaml @@ -0,0 +1,9 @@ +kind: Feature +body: |+ + Improve the list of calendar in the search results: make all calendar clicable, and display a list of calendars + + + +time: 2024-06-13T18:06:48.625006204+02:00 +custom: + Issue: "122" diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js b/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js index 56a8ce563..4d96d095b 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/chill/chill.js @@ -1 +1,2 @@ import './scss/badge.scss'; +import './scss/calendar-list.scss'; diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar-list.scss b/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar-list.scss new file mode 100644 index 000000000..c232b78e2 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Resources/public/chill/scss/calendar-list.scss @@ -0,0 +1,26 @@ +ul.calendar-list { + list-style-type: none; + padding: 0; + & > li { + display: inline-block; + } + & > li:nth-child(n+2) { + margin-left: 0.25rem; + } +} + +div.calendar-list { + + ul.calendar-list { + display: inline-block; + } + + & > a.calendar-list__global { + display: inline-block;; + padding: 0.2rem; + min-width: 2rem; + border: 1px solid var(--bs-chill-blue); + border-radius: 0.25rem; + text-align: center; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig index b03edc7aa..c48771aac 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig @@ -171,7 +171,24 @@

{{ 'chill_calendar.Next calendars'|trans }}

- {% for c in calendars %}{{ c.startDate|format_datetime('long', 'short') }}{% if not loop.last %}, {% endif %}{% endfor %} +
+ + {% if is_granted('CHILL_CALENDAR_CALENDAR_SEE', acp) %} + + {% endif %} +
From 3e4495dd6ef602b2754c0e32fc47caed297ed3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 13 Jun 2024 18:02:48 +0200 Subject: [PATCH 2/2] Refactor AccompanyingPeriod::getNextCalendarForPerson to enhance performance --- .../Entity/AccompanyingPeriod.php | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 03a587620..569e3449a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -869,19 +869,24 @@ class AccompanyingPeriod implements public function getNextCalendarsForPerson(Person $person, $limit = 5): ReadableCollection { $today = new \DateTimeImmutable('today'); - $criteria = Criteria::create() - ->where(Criteria::expr()->gte('startDate', $today)) - // ->andWhere(Criteria::expr()->memberOf('persons', $person)) - ->orderBy(['startDate' => 'DESC']) - ->setMaxResults($limit * 2); - return $this->calendars->matching($criteria) - ->matching( - // due to a bug, filter two times - Criteria::create() - ->where(Criteria::expr()->memberOf('persons', $person)) - ->setMaxResults($limit) - ); + $criteria = Criteria::create(); + $expr = Criteria::expr(); + + $criteria + ->where( + $expr->gte('startDate', $today), + ) + ->orderBy(['startDate' => 'ASC']); + + $criteriaByPerson = Criteria::create(); + $criteriaByPerson + ->where( + $expr->memberOf('persons', $person) + ) + ->setMaxResults($limit); + + return $this->calendars->matching($criteria)->matching($criteriaByPerson); } /**