diff --git a/.changes/unreleased/Feature-20240613-122102.yaml b/.changes/unreleased/Feature-20240613-122102.yaml new file mode 100644 index 000000000..6c9c93e3d --- /dev/null +++ b/.changes/unreleased/Feature-20240613-122102.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: Add flash menu buttons in search results, to open directly a new calendar, or + a new activity in an accompanying period +time: 2024-06-13T12:21:02.602847716+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseQuickMenuBuilder.php b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseQuickMenuBuilder.php new file mode 100644 index 000000000..86052c2be --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Menu/AccompanyingCourseQuickMenuBuilder.php @@ -0,0 +1,51 @@ +security->isGranted(ActivityVoter::CREATE, $accompanyingCourse)) { + $menu + ->addChild('Create a new activity in accompanying course', [ + 'route' => 'chill_activity_activity_new', + 'routeParameters' => [ + // 'activityType_id' => '', + 'accompanying_period_id' => $accompanyingCourse->getId(), + ], + ]) + ->setExtras([ + 'order' => 10, + 'icon' => 'plus', + ]) + ; + } + } +} diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php index bf2ed78a0..dd51a1f55 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php @@ -145,7 +145,7 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn throw new \RuntimeException('Could not determine context of activity.'); } } elseif ($subject instanceof AccompanyingPeriod) { - if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { + if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep() || AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) { if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE], true)) { return false; } diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index cb5ffb982..7e72bc016 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -222,6 +222,7 @@ Documents label: Libellé du champ Documents # activity type category admin ActivityTypeCategory list: Liste des catégories des types d'échange Create a new activity type category: Créer une nouvelle catégorie de type d'échange +Create a new activity in accompanying course: Créer un échange dans le parcours # activity delete Remove activity: Supprimer un échange diff --git a/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseQuickMenuBuilder.php b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseQuickMenuBuilder.php new file mode 100644 index 000000000..6b5108d57 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Menu/AccompanyingCourseQuickMenuBuilder.php @@ -0,0 +1,50 @@ +security->isGranted(CalendarVoter::CREATE, $accompanyingCourse)) { + $menu + ->addChild('Create a new calendar in accompanying course', [ + 'route' => 'chill_calendar_calendar_new', + 'routeParameters' => [ + 'accompanying_period_id' => $accompanyingCourse->getId(), + ], + ]) + ->setExtras([ + 'order' => 20, + 'icon' => 'plus', + ]) + ; + } + } +} diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php index 8f4c3a065..b7aae9349 100644 --- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php +++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php @@ -89,7 +89,7 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn switch ($attribute) { case self::SEE: case self::CREATE: - if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) { + if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep() || AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { return false; } diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index d157683e0..cfb2fe057 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -26,6 +26,7 @@ The calendar item has been successfully removed.: Le rendez-vous a été supprim From the day: Du to the day: au Transform to activity: Transformer en échange +Create a new calendar in accompanying course: Créer un rendez-vous dans le parcours Will send SMS: Un SMS de rappel sera envoyé Will not send SMS: Aucun SMS de rappel ne sera envoyé SMS already sent: Un SMS a été envoyé diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/quick_menu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/quick_menu.html.twig new file mode 100644 index 000000000..9e048d706 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/quick_menu.html.twig @@ -0,0 +1,20 @@ +{% if menus|length > 0 %} +