diff --git a/.changes/unreleased/Fixed-20240916-151843.yaml b/.changes/unreleased/Fixed-20240916-151843.yaml new file mode 100644 index 000000000..ba89d3a70 --- /dev/null +++ b/.changes/unreleased/Fixed-20240916-151843.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Show only the current referrer in the page "show" for an accompanying period + workf +time: 2024-09-16T15:18:43.017401122+02:00 +custom: + Issue: "308" diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php index 6299c6977..af012c5ff 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWork.php @@ -290,7 +290,13 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues } /** - * @return ReadableCollection + * Retrieves a collection of current referrers. + * + * This method filters the referrer history to get only those entries + * where the end date is null, maps them to their associated users, + * and returns them as a new ReadableCollection. + * + * @return ReadableCollection collection of active referrers */ #[Serializer\Groups(['accompanying_period_work:edit'])] public function getReferrers(): ReadableCollection @@ -303,6 +309,18 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues return new ArrayCollection(array_values($users)); } + /** + * @return ReadableCollection + */ + public function getReferrersHistoryCurrent(): ReadableCollection + { + return new ArrayCollection( + $this->getReferrersHistory() + ->filter(fn (AccompanyingPeriodWorkReferrerHistory $h) => null === $h->getEndDate()) + ->getValues() + ); + } + /** * @return Collection */ diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig index 6477f4a95..737a8af24 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/_item.html.twig @@ -83,10 +83,10 @@
{%- if w.referrers|length > 0 -%} - {% for r in w.referrersHistory %} + {% for r in w.referrersHistoryCurrent %} {{ r.user|chill_entity_render_box({'at_date': r.startDate}) }} - {% if not loop.last %}, {% endif %} + {%- if not loop.last %}, {% endif %} {% endfor %} {% else %}