adding crud to manage marital statuses in admin area (CRUDController way, minimal study case)

This commit is contained in:
Mathieu Jaumotte 2021-02-05 18:13:46 +01:00
parent 1839d829bc
commit 5c9e88784f
8 changed files with 149 additions and 2 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
/**
* Class AdminMaritalStatusController
*
* @package Chill\PersonBundle\Controller
*/
class AdminMaritalStatusController extends CRUDController
{
// for minimal cases, nothing is required here !
}

View File

@ -282,6 +282,27 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
'template' => '@ChillPerson/ClosingMotive/edit.html.twig',
]
]
],
[
'class' => \Chill\PersonBundle\Entity\MaritalStatus::class,
'name' => 'marital_status',
'base_path' => '/admin/marital-status',
'form_class' => \Chill\PersonBundle\Form\MaritalStatusType::class,
'controller' => \Chill\PersonBundle\Controller\AdminMaritalStatusController::class,
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/MaritalStatus/index.html.twig',
],
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/MaritalStatus/new.html.twig',
],
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/MaritalStatus/edit.html.twig',
]
]
]
]
]);

View File

@ -0,0 +1,45 @@
<?php
namespace Chill\PersonBundle\Form;
use Symfony\Component\Form\AbstractType;
use Chill\PersonBundle\Entity\MaritalStatus;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Class MaritalStatusType
*
* @package Chill\PersonBundle\Form
*/
class MaritalStatusType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', TextType::class, [
'label' => 'Identifiant'
])
->add('name', TranslatableStringFormType::class, [
'label' => 'Nom'
])
;
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('class', MaritalStatus::class)
;
}
}

View File

@ -38,6 +38,15 @@
<p>{{ 'person_admin.closing motive explanation'|trans }}</p>
</li>
<li>
<p>
<a href="{{ path('chill_crud_marital_status_index') }}">
<strong>{{ 'person_admin.marital status list'|trans }}</strong>
</a>
</p>
<p>{{ 'person_admin.marital status explanation'|trans }}</p>
</li>
</ul>
</div>

View File

@ -0,0 +1,12 @@
{% extends '@ChillMain/Admin/layout.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_view %}{% endblock %}
{% block content_form_actions_save_and_show %}{% endblock %}
{% endembed %}
{% endblock %}

View File

@ -0,0 +1,27 @@
{% extends '@ChillMain/Admin/layout.html.twig' %}
{% block admin_content %}
{% embed '@ChillMain/CRUD/_index.html.twig' %}
{% block table_entities_thead_tr %}
<th>{{ 'Id'|trans }}</th>
<th>{{ 'Name'|trans }}</th>
<th>&nbsp;</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.id }}</td>
<td>{{ entity.name|localize_translatable_string }}</td>
<td>
<ul class="record_actions">
<li>
<a href="{{ chill_path_add_return_path('chill_crud_marital_status_edit', { 'id': entity.id }) }}" class="sc-button bt-edit"></a>
</li>
</ul>
</td>
</tr>
{% endfor %}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends '@ChillMain/Admin/layout.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 %}

View File

@ -229,7 +229,12 @@ crud:
add_new: Ajouter un nouveau
title_new: Nouveau motif de clotûre
title_edit: Modifier le motif de clotûre
marital_status:
index:
title: Liste des états civils
add_new: Ajouter un nouveau
title_new: Nouvel état civil
title_edit: Modifier l'état civil
# specific to closing motive
closing_motive:
@ -243,9 +248,11 @@ person_admin:
closing motive explanation: >
Les motifs de clotûre donnent des indications sur la fermeture
d'une période d'accompagnement.
marital status list: Liste des états civils
marital status explanation: >
Configurer la liste des états civils.
accompanying_period:
dates: Période
dates_from_%opening_date%: Ouvert depuis le %opening_date%
dates_from_%opening_date%_to_%closing_date%: Ouvert du %opening_date% au %closing_date%