From 6f58a9a8bbed28f19668656b23698149354d3a74 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Mar 2022 11:06:00 +0100 Subject: [PATCH 1/2] separate create page --- .../Controller/PersonResourceController.php | 18 ++++++++-- .../views/PersonResource/create.html.twig | 34 ++++++++++++------- .../views/PersonResource/list.html.twig | 12 +++++-- .../ChillPersonBundle/config/routes.yaml | 4 +++ 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index 210b507e5..004961594 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -133,6 +133,19 @@ final class PersonResourceController extends AbstractController $personResources = []; $personResources = $this->personResourceRepository->findBy(['personOwner' => $personOwner->getId()]); + return $this->render( + 'ChillPersonBundle:PersonResource:list.html.twig', + [ + 'person' => $personOwner, + 'personResources' => $personResources, + ] + ); + } + + public function newAction(Request $request, $person_id) + { + $personOwner = $this->personRepository->find($person_id); + $form = $this->createForm(PersonResourceType::class); $form->handleRequest($request); @@ -165,11 +178,10 @@ final class PersonResourceController extends AbstractController } return $this->render( - 'ChillPersonBundle:PersonResource:list.html.twig', + 'ChillPersonBundle:PersonResource:create.html.twig', [ - 'person' => $personOwner, - 'personResources' => $personResources, 'form' => $form->createView(), + 'person' => $personOwner, ] ); } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig index 8fea0bd70..e64d76362 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -1,15 +1,25 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = 'chill_person_resource_list' %} + +{% block title %}{{ 'Person resources'|trans|capitalize ~ ' ' ~ person|chill_entity_render_string }}{% endblock %} + +{% block js %} + {{ encore_entry_script_tags('page_person_resource_showhide_input') }} + {{ encore_entry_script_tags('mod_pickentity_type') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('page_person_resource_showhide_input') }} + {{ encore_entry_link_tags('mod_pickentity_type') }} +{% endblock %} + +{% block personcontent %} + +

{{ 'Add a person resource'|trans }}

+
-

{{ 'Add a person resource'|trans }}

{% include "@ChillPerson/PersonResource/form.html.twig" %} -
- - - -
\ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index 1d480614f..6ccf1a0eb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -85,8 +85,14 @@

{{ 'There are no available resources'|trans }}

{% endif %} -

{{ 'Add a person resource'|trans }}

- -{% include "@ChillPerson/PersonResource/create.html.twig" %} +{% if is_granted('CHILL_PERSON_UPDATE', person) %} + +{% endif %} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/config/routes.yaml b/src/Bundle/ChillPersonBundle/config/routes.yaml index 13d1c1227..1836826c5 100644 --- a/src/Bundle/ChillPersonBundle/config/routes.yaml +++ b/src/Bundle/ChillPersonBundle/config/routes.yaml @@ -59,6 +59,10 @@ chill_person_resource_list: path: /{_locale}/person/{person_id}/resources/list controller: Chill\PersonBundle\Controller\PersonResourceController::listAction +chill_person_resource_new: + path: /{_locale}/person/{person_id}/resources/new + controller: Chill\PersonBundle\Controller\PersonResourceController::newAction + chill_person_resource_edit: path: /{_locale}/person/{person_id}/resources/{resource_id}/edit controller: Chill\PersonBundle\Controller\PersonResourceController::editAction From 85552778271592727180423f04fa256d7e31ab1d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Mar 2022 11:06:10 +0100 Subject: [PATCH 2/2] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f0f00749..e26caae71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to * [person] Change 'personne' with 'usager' and '&' with 'ET' (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/499) * [thirdparty] Add parameter condition to display centers or not (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/500) * [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496) +* [person_resource] separate create page created to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/504) ## Test releases