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 %} + +{% endif %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuTwig.php b/src/Bundle/ChillMainBundle/Routing/MenuTwig.php index 7431833ab..b8fa40d25 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuTwig.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuTwig.php @@ -11,8 +11,6 @@ declare(strict_types=1); namespace Chill\MainBundle\Routing; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -20,10 +18,8 @@ use Twig\TwigFunction; /** * Add the filter 'chill_menu'. */ -class MenuTwig extends AbstractExtension implements ContainerAwareInterface +class MenuTwig extends AbstractExtension { - private ?ContainerInterface $container = null; - /** * the default parameters for chillMenu. * @@ -86,9 +82,4 @@ class MenuTwig extends AbstractExtension implements ContainerAwareInterface { return 'chill_menu'; } - - public function setContainer(?ContainerInterface $container = null) - { - $this->container = $container; - } } diff --git a/src/Bundle/ChillMainBundle/config/services/routing.yaml b/src/Bundle/ChillMainBundle/config/services/routing.yaml index 4363c068f..90ce6066f 100644 --- a/src/Bundle/ChillMainBundle/config/services/routing.yaml +++ b/src/Bundle/ChillMainBundle/config/services/routing.yaml @@ -20,9 +20,5 @@ services: chill.main.twig.chill_menu: class: Chill\MainBundle\Routing\MenuTwig - arguments: - - "@chill.main.menu_composer" - calls: - - [setContainer, ["@service_container"]] tags: - { name: twig.extension } diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonQuickMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonQuickMenuBuilder.php new file mode 100644 index 000000000..5534791e4 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Menu/PersonQuickMenuBuilder.php @@ -0,0 +1,51 @@ +authorizationChecker->isGranted(AccompanyingPeriodVoter::CREATE, $person)) { + $menu->addChild( + 'Create Accompanying Course', + [ + 'route' => 'chill_person_accompanying_course_new', + 'routeParameters' => [ + 'person_id' => [$person->getId()], + ], + ] + ) + ->setExtras([ + 'order' => 10, + 'icon' => 'plus', + ]); + } + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/flex_table.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/flex_table.scss index 30cac9c85..86bc775f7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/flex_table.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/flex_table.scss @@ -30,7 +30,7 @@ div.list-with-period { // override wrap-list div.wrap-list.periods-list { - padding-right: 1rem; + padding-right: 0; div.wl-row { flex-wrap: nowrap; div.wl-col { 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 7dcf5a5bf..b03edc7aa 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 @@ -1,13 +1,19 @@ +{% macro button_person_before(person) %} + {{ chill_menu('person_quick_menu', { + 'layout': '@ChillMain/Menu/quick_menu.html.twig', + 'args' : { 'person': person } + }) }} +{% endmacro %} + {% macro button_person_after(person) %} {% set household = person.getCurrentHousehold %} {% if household is not null and is_granted('CHILL_PERSON_HOUSEHOLD_SEE', household) %}
  • - -
  • - {% endif %} - {% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE', person) %} -
  • - + +
  • {% endif %} {% endmacro %} @@ -184,13 +190,20 @@ {% endif %} -