diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 550c6e984..5f1b70aa0 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -526,14 +526,20 @@ class CalendarController extends AbstractController 'comment' => $calendar->getComment()->getComment(), ]; - return $this->redirectToRoute( - 'chill_activity_activity_new', - [ - 'accompanying_period_id' => $calendar->getAccompanyingPeriod()->getId(), - 'activityData' => $activityData, - 'returnPath' => $request->query->get('returnPath', null), - ] - ); + $routeParams = [ + 'activityData' => $activityData, + 'returnPath' => $request->query->get('returnPath', null), + ]; + + if ($calendar->getContext() === 'accompanying_period'){ + $routeParams['accompanying_period_id'] = $calendar->getAccompanyingPeriod()->getId(); + } elseif ($calendar->getContext() === 'person') { + $routeParams['person_id'] = $calendar->getPerson()->getId(); + } else { + throw new RuntimeException('context not found for this calendar'); + } + + return $this->redirectToRoute('chill_activity_activity_new', $routeParams); } private function buildListFilterOrder(): FilterOrderHelper diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig index d6110917a..c09be27b7 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig @@ -103,6 +103,42 @@ {% endif %} + {% if calendar.activity is not null %} +