mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
ChillPersonBundle: Add numberOfDependents and numberOfDependentsWithDisabilities
This commit is contained in:
parent
5f31473c90
commit
fbdc0d32f0
@ -33,9 +33,12 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Exception;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
class HouseholdMemberController extends ApiController
|
||||
{
|
||||
private array $fields_visibility;
|
||||
|
||||
public function __construct(
|
||||
private readonly UrlGeneratorInterface $generator,
|
||||
private readonly TranslatorInterface $translator,
|
||||
@ -45,7 +48,10 @@ class HouseholdMemberController extends ApiController
|
||||
private readonly Security $security,
|
||||
private readonly PositionRepository $positionRepository,
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
protected ParameterBagInterface $parameterBag,
|
||||
) {
|
||||
$this->fields_visibility = $parameterBag->get('chill_person.person_fields');
|
||||
}
|
||||
|
||||
#[Route(path: '/{_locale}/person/household/member/{id}/edit', name: 'chill_person_household_member_edit')]
|
||||
public function editMembership(Request $request, HouseholdMember $member): Response
|
||||
@ -144,6 +150,7 @@ class HouseholdMemberController extends ApiController
|
||||
'allowHouseholdCreate' => $allowHouseholdCreate ?? true,
|
||||
'allowHouseholdSearch' => $allowHouseholdSearch ?? true,
|
||||
'allowLeaveWithoutHousehold' => $allowLeaveWithoutHousehold ?? $request->query->has('allow_leave_without_household'),
|
||||
'displayDependents' => ('visible' == $this->fields_visibility['number_of_dependents']) ? true : false,
|
||||
];
|
||||
|
||||
// context
|
||||
|
@ -83,6 +83,7 @@ class Configuration implements ConfigurationInterface
|
||||
->append($this->addFieldNode('accompanying_period'))
|
||||
->append($this->addFieldNode('memo'))
|
||||
->append($this->addFieldNode('number_of_children'))
|
||||
->append($this->addFieldNode('number_of_dependents', 'hidden'))
|
||||
->append($this->addFieldNode('acceptEmail'))
|
||||
->append($this->addFieldNode('deathdate'))
|
||||
->append($this->addFieldNode('employment_status', 'hidden'))
|
||||
|
@ -58,6 +58,18 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
|
||||
private ?int $numberOfChildren = null;
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Assert\GreaterThanOrEqual(0, groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
|
||||
private ?int $numberOfDependents = null;
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Assert\GreaterThanOrEqual(0, groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
|
||||
private ?int $numberOfDependentsWithDisabilities = null;
|
||||
|
||||
#[Assert\NotNull(groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: false)]
|
||||
@ -98,6 +110,16 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
|
||||
return $this->numberOfChildren;
|
||||
}
|
||||
|
||||
public function getNumberOfDependents(): ?int
|
||||
{
|
||||
return $this->numberOfDependents;
|
||||
}
|
||||
|
||||
public function getNumberOfDependentsWithDisabilities(): ?int
|
||||
{
|
||||
return $this->numberOfDependentsWithDisabilities;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
@ -142,6 +164,20 @@ class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setNumberOfDependents(?int $numberOfDependents): HouseholdComposition
|
||||
{
|
||||
$this->numberOfDependents = $numberOfDependents;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setNumberOfDependentsWithDisabilities(?int $numberOfDependentsWithDisabilities): HouseholdComposition
|
||||
{
|
||||
$this->numberOfDependentsWithDisabilities = $numberOfDependentsWithDisabilities;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(?\DateTimeImmutable $startDate): HouseholdComposition
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
@ -19,10 +19,19 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
class HouseholdCompositionType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly HouseholdCompositionTypeRepository $householdCompositionTypeRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
|
||||
private array $fields_visibility;
|
||||
|
||||
public function __construct(
|
||||
private readonly HouseholdCompositionTypeRepository $householdCompositionTypeRepository,
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
protected ParameterBagInterface $parameterBag,
|
||||
) {
|
||||
$this->fields_visibility = $parameterBag->get('chill_person.person_fields');
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
@ -42,7 +51,19 @@ class HouseholdCompositionType extends AbstractType
|
||||
->add('numberOfChildren', IntegerType::class, [
|
||||
'required' => true,
|
||||
'label' => 'household_composition.numberOfChildren',
|
||||
])
|
||||
]);
|
||||
if ('visible' == $this->fields_visibility['number_of_dependents']) {
|
||||
$builder
|
||||
->add('numberOfDependents', IntegerType::class, [
|
||||
'required' => true,
|
||||
'label' => 'household_composition.numberOfDependents',
|
||||
])
|
||||
->add('numberOfDependentsWithDisabilities', IntegerType::class, [
|
||||
'required' => true,
|
||||
'label' => 'household_composition.numberOfDependentsWithDisabilities',
|
||||
]);
|
||||
}
|
||||
$builder
|
||||
->add('comment', CommentType::class, [
|
||||
'required' => false,
|
||||
]);
|
||||
|
@ -47,6 +47,36 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="this.displayDependents" class="mb-3 row">
|
||||
<label class="col-form-label col-sm-4 required">{{
|
||||
$t("household_members_editor.composition.number_of_dependents")
|
||||
}}</label>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="number"
|
||||
v-model="numberOfDependents"
|
||||
min="0"
|
||||
max="30"
|
||||
class="form-control"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="this.displayDependents" class="mb-3 row">
|
||||
<label class="col-form-label col-sm-4 required">{{
|
||||
$t(
|
||||
"household_members_editor.composition.number_of_dependents_with_disabilities",
|
||||
)
|
||||
}}</label>
|
||||
<div class="col-sm-8">
|
||||
<input
|
||||
type="number"
|
||||
v-model="numberOfDependentsWithDisabilities"
|
||||
min="0"
|
||||
max="30"
|
||||
class="form-control"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -62,6 +92,11 @@ export default {
|
||||
computed: {
|
||||
...mapState(["householdCompositionTypes"]),
|
||||
...mapGetters(["isHouseholdNew"]),
|
||||
displayDependents: {
|
||||
get() {
|
||||
return window.household_members_editor_data.displayDependents;
|
||||
},
|
||||
},
|
||||
householdCompositionType: {
|
||||
get() {
|
||||
if (this.$store.state.householdCompositionType !== null) {
|
||||
@ -81,6 +116,22 @@ export default {
|
||||
this.$store.commit("setNumberOfChildren", value);
|
||||
},
|
||||
},
|
||||
numberOfDependents: {
|
||||
get() {
|
||||
return this.$store.state.numberOfDependents;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit("setNumberOfDependents", value);
|
||||
},
|
||||
},
|
||||
numberOfDependentsWithDisabilities: {
|
||||
get() {
|
||||
return this.$store.state.numberOfDependentsWithDisabilities;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit("setNumberOfDependentsWithDisabilities", value);
|
||||
},
|
||||
},
|
||||
startDate: {
|
||||
get() {
|
||||
return this.$store.state.startDate;
|
||||
|
@ -91,6 +91,9 @@ const appMessages = {
|
||||
composition: "Composition familiale",
|
||||
household_composition: "Composition du ménage",
|
||||
number_of_children: "Nombre d'enfants mineurs au sein du ménage",
|
||||
number_of_dependents: "Nombre de personnes majeures à charge",
|
||||
number_of_dependents_with_disabilities:
|
||||
"Nombre de personnes à charge reconnues handicapées",
|
||||
},
|
||||
confirmation: {
|
||||
save: "Enregistrer",
|
||||
|
@ -73,6 +73,8 @@ const store = createStore({
|
||||
window.household_members_editor_expand_suggestions === 1,
|
||||
householdCompositionType: null,
|
||||
numberOfChildren: 0,
|
||||
numberOfDependents: 0,
|
||||
numberOfDependentsWithDisabilities: 0,
|
||||
addressesSuggestion: [],
|
||||
showAddressSuggestion: true,
|
||||
householdCompositionTypes: [],
|
||||
@ -322,6 +324,9 @@ const store = createStore({
|
||||
start_date: {
|
||||
datetime: datetimeToISO(ISOToDate(state.startDate)),
|
||||
},
|
||||
number_of_dependents: state.numberOfDependents,
|
||||
number_of_dependents_with_disabilities:
|
||||
state.numberOfDependentsWithDisabilities,
|
||||
};
|
||||
}
|
||||
|
||||
@ -455,6 +460,12 @@ const store = createStore({
|
||||
setNumberOfChildren(state, number) {
|
||||
state.numberOfChildren = Number.parseInt(number);
|
||||
},
|
||||
setNumberOfDependents(state, number) {
|
||||
state.numberOfDependents = Number.parseInt(number);
|
||||
},
|
||||
setNumberOfDependentsWithDisabilities(state, number) {
|
||||
state.numberOfDependentsWithDisabilities = Number.parseInt(number);
|
||||
},
|
||||
addAddressesSuggestion(state, addresses) {
|
||||
let existingIds = state.addressesSuggestion.map((a) => a.address_id);
|
||||
|
||||
|
@ -63,6 +63,12 @@
|
||||
</h6>
|
||||
<p>
|
||||
{{ 'household_composition.numberOfChildren children in household'|trans({'numberOfChildren': currentComposition.numberOfChildren}) }}
|
||||
{% if chill_person.fields.number_of_dependents == 'visible' %}
|
||||
<br />
|
||||
{{ 'household_composition.numberOfDependents adult dependents'|trans({'numberOfDependents': currentComposition.numberOfDependents}) }}
|
||||
<br />
|
||||
{{ 'household_composition.numberOfDependentsWithDisabilities dependents with disabilities'|trans({'numberOfDependentsWithDisabilities': currentComposition.numberOfDependentsWithDisabilities}) }}
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
{{ 'household_composition.Since'|trans({'startDate': currentComposition.startDate}) }}
|
||||
|
@ -21,6 +21,10 @@
|
||||
<div class="item-col">
|
||||
<h3>{{ c.householdCompositionType.label|localize_translatable_string }}</h3>
|
||||
<p>{{ 'household_composition.numberOfChildren'|trans }}: {{ c.numberOfChildren }}</p>
|
||||
{% if chill_person.fields.number_of_dependents == 'visible' %}
|
||||
<p>{{ 'household_composition.numberOfDependents'|trans }}: {{ c.numberOfDependents }}</p>
|
||||
<p>{{ 'household_composition.numberOfDependentsWithDisabilities'|trans }}: {{ c.numberOfDependentsWithDisabilities }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="item-col" style="justify-content: flex-end">{{ 'household_composition.Since'|trans({'startDate': c.startDate}) }}</div>
|
||||
</div>
|
||||
|
@ -206,6 +206,28 @@ This view should receive those arguments:
|
||||
</dd>
|
||||
</dl>
|
||||
{%- endif -%}
|
||||
{%- if chill_person.fields.number_of_dependents == 'isible' -%}
|
||||
<dl>
|
||||
<dt>{{'Number of dependents'|trans}} :</dt>
|
||||
<dd>
|
||||
{% if person.numberOfDependents is not null %}
|
||||
{{ person.numberOfDependents }}
|
||||
{% else %}
|
||||
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>{{'Number of dependents with disabilities'|trans}} :</dt>
|
||||
<dd>
|
||||
{% if person.numberOfDependents is not null %}
|
||||
{{ person.numberOfDependentsWithDisabilities }}
|
||||
{% else %}
|
||||
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
{%- endif -%}
|
||||
{%- if chill_person.fields.marital_status == 'visible' -%}
|
||||
<dl>
|
||||
<dt>{{'Marital status'|trans}} :</dt>
|
||||
|
@ -147,6 +147,8 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
|
||||
if (null !== $data['composition']) {
|
||||
$compositionType = $this->denormalizer->denormalize($data['composition']['household_composition_type'], HouseholdCompositionType::class, $format, $context);
|
||||
$numberOfChildren = $data['composition']['number_of_children'];
|
||||
$numberOfDependents = $data['composition']['number_of_dependents'];
|
||||
$numberOfDependentsWithDisabilities = $data['composition']['number_of_dependents_with_disabilities'];
|
||||
$startDate = $this->denormalizer->denormalize($data['composition']['start_date'], \DateTimeImmutable::class, $format, $context);
|
||||
|
||||
if (null === $compositionType) {
|
||||
@ -156,6 +158,8 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
|
||||
$householdComposition = (new HouseholdComposition())
|
||||
->setHouseholdCompositionType($compositionType)
|
||||
->setNumberOfChildren($numberOfChildren)
|
||||
->setNumberOfDependents($numberOfDependents)
|
||||
->setNumberOfDependentsWithDisabilities($numberOfDependentsWithDisabilities)
|
||||
->setStartDate($startDate);
|
||||
|
||||
$household->addComposition($householdComposition);
|
||||
|
@ -14,9 +14,6 @@ namespace Chill\Migrations\Person;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20241127160628 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20241220102357 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add numberOfDependents and numberOfDependentsWithDisabilities';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_household_composition ADD numberOfDependents INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_household_composition ADD numberOfDependentsWithDisabilities INT DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_household_composition DROP numberOfDependents');
|
||||
$this->addSql('ALTER TABLE chill_person_household_composition DROP numberOfDependentsWithDisabilities');
|
||||
}
|
||||
}
|
@ -116,6 +116,20 @@ household_composition:
|
||||
few {# enfants dans le ménage}
|
||||
other {# enfants dans le ménage}
|
||||
}
|
||||
numberOfDependents adult dependents: >-
|
||||
{numberOfDependents, plural,
|
||||
=0 {Aucune personne majeure à charge}
|
||||
one {1 personne majeure à charge}
|
||||
few {# personnes majeures à charge}
|
||||
other {# personnes majeures à charge}
|
||||
}
|
||||
numberOfDependentsWithDisabilities dependents with disabilities: >-
|
||||
{numberOfDependentsWithDisabilities, plural,
|
||||
=0 {Aucune personne à charge reconnue handicapée}
|
||||
one {1 personne à charge reconnue handicapée}
|
||||
few {# personnes à charge reconnue handicapée}
|
||||
other {# personnes à charge reconnue handicapée}
|
||||
}
|
||||
|
||||
periods:
|
||||
title: Parcours d'accompagnement (n°{id})
|
||||
|
@ -963,6 +963,8 @@ household_composition:
|
||||
Add a composition: Ajouter une composition familiale
|
||||
Update composition: Modifier la composition familiale
|
||||
Create: Créér une nouvelle composition familiale
|
||||
numberOfDependents: Nombre de personnes majeures à charges
|
||||
numberOfDependentsWithDisabilities: Nombre de personnes à charge reconnues handicapées
|
||||
|
||||
# docgen
|
||||
Linked evaluations: Évaluations associées
|
||||
|
Loading…
x
Reference in New Issue
Block a user