admin: add household position and relation admin

This commit is contained in:
nobohan 2022-05-05 18:31:08 +02:00
parent 9ce7f10415
commit 7907e4a050
15 changed files with 370 additions and 21 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 HouseholdPositionController 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

@ -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 RelationController 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,48 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
],
],
],
[
'class' => \Chill\PersonBundle\Entity\Household\Position::class,
'name' => 'person_household_position',
'base_path' => '/admin/person/household/position',
'form_class' => \Chill\PersonBundle\Form\HouseholdPositionType::class,
'controller' => \Chill\PersonBundle\Controller\HouseholdPositionController::class,
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/HouseholdPosition/index.html.twig',
],
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/HouseholdPosition/new.html.twig',
],
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/HouseholdPosition/edit.html.twig',
],
],
],
[
'class' => \Chill\PersonBundle\Entity\Relationships\Relation::class,
'name' => 'person_relation',
'base_path' => '/admin/person/relation',
'form_class' => \Chill\PersonBundle\Form\RelationType::class,
'controller' => \Chill\PersonBundle\Controller\RelationController::class,
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/Relation/index.html.twig',
],
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/Relation/new.html.twig',
],
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillPerson/Relation/edit.html.twig',
],
],
],
[
'class' => \Chill\PersonBundle\Entity\Person\PersonResourceKind::class,
'name' => 'person_resource-kind',

View File

@ -0,0 +1,47 @@
<?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\Household\Position;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class HouseholdPositionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('label', TranslatableStringFormType::class)
->add('allowHolder', CheckboxType::class, [
'required' => false,
'label' => 'household.allowHolder',
])
->add('shareHousehold', CheckboxType::class, [
'required' => false,
'label' => 'household.shareHousehold',
])
->add('ordering', NumberType::class, [
'required' => true,
'scale' => 5,
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('class', Position::class);
}
}

View File

@ -27,7 +27,7 @@ class OriginType extends AbstractType
->add('noActiveAfter', ChillDateType::class, [
'required' => false,
'input' => 'datetime_immutable',
'label' => 'origin.noActiveAfter'
'label' => 'origin.noActiveAfter',
]);
}

View File

@ -25,11 +25,11 @@ class PersonResourceKindType extends AbstractType
$builder
->add('title', TranslatableStringFormType::class)
->add('isActive', ChoiceType::class, [
'choices' => [
'Active' => true,
'Inactive' => false,
],
]);
'choices' => [
'Active' => true,
'Inactive' => false,
],
]);
}
public function configureOptions(OptionsResolver $resolver)

View File

@ -0,0 +1,42 @@
<?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\Relationships\Relation;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class RelationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TranslatableStringFormType::class, [
'label' => 'relation.title',
])
->add('reverseTitle', TranslatableStringFormType::class, [
'label' => 'relation.reverseTitle',
])
->add('isActive', CheckboxType::class, [
'required' => false,
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('class', Relation::class);
}
}

View File

@ -49,43 +49,53 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface
'route' => 'chill_crud_person_resource-kind_index',
])->setExtras(['order' => 2030]);
$menu->addChild('person_admin.accompanying_period')
$menu->addChild('Household')
->setAttribute('class', 'list-group-item-header')
->setExtras(['order' => 2100, 'header' => true]);
$menu->addChild('person_admin.closing motives', [
'route' => 'chill_crud_closing_motive_index',
$menu->addChild('Position', [
'route' => 'chill_crud_person_household_position_index',
])->setExtras(['order' => 2110]);
$menu->addChild('person_admin.origin', [
'route' => 'chill_crud_origin_index',
])->setExtras(['order' => 2110]);
$menu->addChild('person_admin.relation', [
'route' => 'chill_crud_person_relation_index',
])->setExtras(['order' => 2120]);
$menu->addChild('person_admin.social_work')
$menu->addChild('person_admin.accompanying_period')
->setAttribute('class', 'list-group-item-header')
->setExtras(['order' => 2200, 'header' => true]);
$menu->addChild('person_admin.closing motives', [
'route' => 'chill_crud_closing_motive_index',
])->setExtras(['order' => 2210]);
$menu->addChild('person_admin.origin', [
'route' => 'chill_crud_origin_index',
])->setExtras(['order' => 2210]);
$menu->addChild('person_admin.social_work')
->setAttribute('class', 'list-group-item-header')
->setExtras(['order' => 2300, 'header' => true]);
$menu->addChild('person_admin.social_action', [
'route' => 'chill_crud_social_action_index',
])->setExtras(['order' => 2201]);
])->setExtras(['order' => 2301]);
$menu->addChild('person_admin.social_issue', [
'route' => 'chill_crud_social_issue_index',
])->setExtras(['order' => 2202]);
])->setExtras(['order' => 2302]);
$menu->addChild('person_admin.social_goal', [
'route' => 'chill_crud_social_goal_index',
])->setExtras(['order' => 2210]);
])->setExtras(['order' => 2310]);
$menu->addChild('person_admin.social_evaluation', [
'route' => 'chill_crud_social_evaluation_index',
])->setExtras(['order' => 2220]);
])->setExtras(['order' => 2320]);
$menu->addChild('person_admin.social_result', [
'route' => 'chill_crud_social_result_index',
])->setExtras(['order' => 2230]);
])->setExtras(['order' => 2330]);
}
public static function getMenuIds(): array

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,49 @@
{% 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>{{ 'Label'|trans }}</th>
<th>{{ 'household.allowHolder'|trans }}</th>
<th>{{ 'household.shareHousehold'|trans }}</th>
<th>&nbsp;</th>
{% endblock %}
{% block table_entities_tbody %}
{% for entity in entities %}
<tr>
<td>{{ entity.id }}</td>
<td>{{ entity.label|localize_translatable_string }}</td>
<td style="text-align:center;">
{%- if entity.allowHolder -%}
<i class="fa fa-check-square-o"></i>
{%- else -%}
<i class="fa fa-square-o"></i>
{%- endif -%}
</td>
<td style="text-align:center;">
{%- if entity.shareHousehold -%}
<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_household_position_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

@ -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 }} - {{ entity.reverseTitle|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_relation_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

@ -390,6 +390,18 @@ crud:
add_new: Ajouter un nouveau
title_new: Nouveau type de personne-ressource
title_edit: Modifier le type de personne-ressource
person_household_position:
index:
title: Position
add_new: Ajouter un nouveau
title_new: Nouvelle position
title_edit: Modifier la position
person_relation:
index:
title: Relations de filiations
add_new: Ajouter un nouveau
title_new: Nouvelle relation de filiation
title_edit: Modifier la relation de filiation
social_issue:
index:
title: Liste des problématiques sociales
@ -436,6 +448,14 @@ socialAction:
defaultNotificationDelay: Délai de notification par défaut
socialIssue: Problématique sociale
household:
allowHolder: Peut être titulaire
shareHousehold: Peut être partagé
relation:
title: Premier membre
reverseTitle: Deuxième membre
# specific to closing motive
closing_motive:
any parent: Aucun parent
@ -462,7 +482,7 @@ person_admin:
social_result: Résultats
social_evaluation: Évaluations
social_work: Accompagnement social
relation: Relations de filiations
# specific to accompanying period
accompanying_period: