From 9ce7f10415dbddbf46bd0b17dc713087bf005124 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 5 May 2022 15:20:47 +0200 Subject: [PATCH] admin: add personresourcekind in the admin --- .../PersonResourceKindController.php | 26 ++++++++++++ .../ChillPersonExtension.php | 21 ++++++++++ .../Form/PersonResourceKindType.php | 40 ++++++++++++++++++ .../Menu/AdminMenuBuilder.php | 5 +++ .../views/PersonResourceKind/edit.html.twig | 11 +++++ .../views/PersonResourceKind/index.html.twig | 41 +++++++++++++++++++ .../views/PersonResourceKind/new.html.twig | 12 ++++++ .../translations/messages.fr.yml | 8 ++++ 8 files changed, 164 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Controller/PersonResourceKindController.php create mode 100644 src/Bundle/ChillPersonBundle/Form/PersonResourceKindType.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/edit.html.twig create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/index.html.twig create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/new.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceKindController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceKindController.php new file mode 100644 index 000000000..ca3047a97 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceKindController.php @@ -0,0 +1,26 @@ +addOrderBy('e.id', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index b29d79e8e..3d88fac22 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -206,6 +206,27 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], ], ], + [ + 'class' => \Chill\PersonBundle\Entity\Person\PersonResourceKind::class, + 'name' => 'person_resource-kind', + 'base_path' => '/admin/person/resource-kind', + 'form_class' => \Chill\PersonBundle\Form\PersonResourceKindType::class, + 'controller' => \Chill\PersonBundle\Controller\PersonResourceKindController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/PersonResourceKind/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/PersonResourceKind/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillPerson/PersonResourceKind/edit.html.twig', + ], + ], + ], [ 'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class, 'name' => 'social_issue', diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceKindType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceKindType.php new file mode 100644 index 000000000..060c7628c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceKindType.php @@ -0,0 +1,40 @@ +add('title', TranslatableStringFormType::class) + ->add('isActive', ChoiceType::class, [ + 'choices' => [ + 'Active' => true, + 'Inactive' => false, + ], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', PersonResourceKind::class); + } +} diff --git a/src/Bundle/ChillPersonBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AdminMenuBuilder.php index 1e563df86..af47d4544 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AdminMenuBuilder.php @@ -45,6 +45,11 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface 'route' => 'chill_crud_person_marital-status_index', ])->setExtras(['order' => 2020]); + $menu->addChild('person_admin.person_resource_kind', [ + 'route' => 'chill_crud_person_resource-kind_index', + ])->setExtras(['order' => 2030]); + + $menu->addChild('person_admin.accompanying_period') ->setAttribute('class', 'list-group-item-header') diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/edit.html.twig new file mode 100644 index 000000000..28678bf6d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/edit.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/index.html.twig new file mode 100644 index 000000000..51105d0ff --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/index.html.twig @@ -0,0 +1,41 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entities_thead_tr %} + {{ 'Id'|trans }} + {{ 'Title'|trans }} + {{ 'Active'|trans }} +   + {% endblock %} + + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.title|localize_translatable_string }} + + {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + + + + + + {% endfor %} + {% endblock %} + + {% block actions_before %} +
  • + {{'Back to the admin'|trans}} +
  • + {% endblock %} + {% endembed %} +{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/new.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/new.html.twig new file mode 100644 index 000000000..3a28dd85f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResourceKind/new.html.twig @@ -0,0 +1,12 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} + diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 92718d1f5..209a955d8 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -384,6 +384,12 @@ crud: add_new: Ajouter un nouveau title_new: Nouvel état civil title_edit: Modifier l'état civil + person_resource-kind: + index: + title: Types de personnes-ressources + add_new: Ajouter un nouveau + title_new: Nouveau type de personne-ressource + title_edit: Modifier le type de personne-ressource social_issue: index: title: Liste des problématiques sociales @@ -449,6 +455,7 @@ person_admin: marital status list: Liste des états civils marital status explanation: > Configurer la liste des états civils. + person_resource_kind: Type de personne ressource social_issue: Problématiques sociales social_action: Actions d'accompagnement social_goal: Buts @@ -456,6 +463,7 @@ person_admin: social_evaluation: Évaluations social_work: Accompagnement social + # specific to accompanying period accompanying_period: dates: Période