From cf041cf49e797702f699c1c9930f9e347042cfae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 24 Jan 2022 19:42:06 +0100 Subject: [PATCH] merge dynamic types --- .../Form/PersonResourceType.php | 22 +++++-------------- .../views/PersonResource/list.html.twig | 20 ++++++++++++----- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php index f99a45f9c..91b1c2643 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -17,9 +17,11 @@ use Chill\MainBundle\Form\Type\CommentType; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person\PersonResource; use Chill\PersonBundle\Entity\Person\PersonResourceKind; +use Chill\PersonBundle\Form\Type\PickPersonDynamicType; use Chill\PersonBundle\Templating\Entity\PersonRender; use Chill\PersonBundle\Templating\Entity\ResourceKindRender; use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType; use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -63,25 +65,11 @@ final class PersonResourceType extends AbstractType return $this->resourceKindRender->renderString($personResourceKind, $options); } ]) - ->add('person', EntityType::class, [ + ->add('person', PickPersonDynamicType::class, [ 'label' => 'Usager', - 'class' => Person::class, - 'placeholder' => $this->translator->trans('Select a person'), - 'required' => false, - 'choice_label' => function (Person $person) { - $options = []; - return $this->personRender->renderString($person, $options); - } ]) - ->add('thirdparty', EntityType::class, [ + ->add('thirdparty', PickThirdpartyDynamicType::class, [ 'label' => 'Tiers', - 'class' => ThirdParty::class, - 'required' => false, - 'placeholder' => $this->translator->trans('Select a thirdparty'), - 'choice_label' => function (ThirdParty $thirdParty) { - $options = []; - return $this->thirdPartyRender->renderString($thirdParty, $options); - } ]) ->add('freetext', ChillTextareaType::class, [ 'label' => 'Description libre', @@ -105,4 +93,4 @@ final class PersonResourceType extends AbstractType return 'chill_personbundle_person_resource'; } -} \ 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 79f05aeed..b572d9d11 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -4,6 +4,20 @@ {% block title %}{{ 'Person resources'|trans|capitalize ~ ' ' ~ person|chill_entity_render_string }}{% endblock %} +{% block js %} + {{ encore_entry_script_tags('page_person_resource_person_input') }} + {{ encore_entry_script_tags('page_person_resource_thirdparty_input') }} + {{ encore_entry_script_tags('page_person_resource_freetext_input') }} + {{ encore_entry_script_tags('mod_pickentity_type') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('page_person_resource_person_input') }} + {{ encore_entry_link_tags('page_person_resource_thirdparty_input') }} + {{ encore_entry_link_tags('page_person_resource_freetext_input') }} + {{ encore_entry_link_tags('mod_pickentity_type') }} +{% endblock %} + {% block personcontent %}

{{ 'List of resources'|trans }}

@@ -91,9 +105,3 @@ {% include "@ChillPerson/PersonResource/create.html.twig" %} {% endblock %} - -{% block js %} - {{ encore_entry_script_tags('page_person_resource_person_input') }} - {{ encore_entry_script_tags('page_person_resource_thirdparty_input') }} - {{ encore_entry_script_tags('page_person_resource_freetext_input') }} -{% endblock %} \ No newline at end of file