admin: add personresourcekind in the admin

This commit is contained in:
nobohan 2022-05-05 15:20:47 +02:00
parent 2fbdd169df
commit 9ce7f10415
8 changed files with 164 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\CRUDController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
class PersonResourceKindController extends CRUDController
{
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
$query->addOrderBy('e.id', 'ASC');
return parent::orderQuery($action, $query, $request, $paginator);
}
}

View File

@ -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',

View File

@ -0,0 +1,40 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Form;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\PersonBundle\Entity\Person\PersonResourceKind;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PersonResourceKindType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TranslatableStringFormType::class)
->add('isActive', ChoiceType::class, [
'choices' => [
'Active' => true,
'Inactive' => false,
],
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('class', PersonResourceKind::class);
}
}

View File

@ -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')

View File

@ -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 %}

View File

@ -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 %}
<th>{{ 'Id'|trans }}</th>
<th>{{ 'Title'|trans }}</th>
<th>{{ 'Active'|trans }}</th>
<th>&nbsp;</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.id }}</td>
<td>{{ entity.title|localize_translatable_string }}</td>
<td style="text-align:center;">
{%- if entity.isActive -%}
<i class="fa fa-check-square-o"></i>
{%- else -%}
<i class="fa fa-square-o"></i>
{%- endif -%}
</td>
<td>
<ul class="record_actions">
<li>
<a href="{{ chill_path_add_return_path('chill_crud_person_resource-kind_edit', { 'id': entity.id }) }}" class="btn btn-edit"></a>
</li>
</ul>
</td>
</tr>
{% endfor %}
{% endblock %}
{% block actions_before %}
<li class='cancel'>
<a href="{{ path('chill_main_admin_central') }}" class="btn btn-cancel">{{'Back to the admin'|trans}}</a>
</li>
{% endblock %}
{% endembed %}
{% endblock %}

View File

@ -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 %}

View File

@ -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