mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
finalize members lists
This commit is contained in:
parent
604e78f35e
commit
5cb076495a
@ -2,17 +2,32 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Form\HouseholdMemberType;
|
||||||
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Serializer\Exception;
|
use Symfony\Component\Serializer\Exception;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
use Chill\PersonBundle\Household\MembersEditor;
|
use Chill\PersonBundle\Household\MembersEditor;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
|
|
||||||
class HouseholdMemberController extends ApiController
|
class HouseholdMemberController extends ApiController
|
||||||
{
|
{
|
||||||
|
private UrlGeneratorInterface $generator;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(UrlGeneratorInterface $generator, TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->generator = $generator;
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/api/1.0/person/household/members/move.{_format}",
|
* "/api/1.0/person/household/members/move.{_format}",
|
||||||
@ -44,4 +59,39 @@ class HouseholdMemberController extends ApiController
|
|||||||
"groups" => ["read"],
|
"groups" => ["read"],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route(
|
||||||
|
* "/api/1.0/person/household/member/{id}/edit",
|
||||||
|
* name="chill_person_household_member_edit"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function editMembership(Request $request, HouseholdMember $member): Response
|
||||||
|
{
|
||||||
|
// TODO ACL
|
||||||
|
|
||||||
|
$form = $this->createForm(HouseholdMemberType::class, $member);
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->translator
|
||||||
|
->trans('household.successfully saved member'))
|
||||||
|
;
|
||||||
|
|
||||||
|
return $this->redirect(
|
||||||
|
$request->get('returnPath', null) ??
|
||||||
|
$this->generator->generate('chill_person_household_members', [ 'household_id' =>
|
||||||
|
$member->getHousehold()->getId() ])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('@ChillPerson/Household/Member/edit.html.twig', [
|
||||||
|
'household' => $member->getHousehold(),
|
||||||
|
'member' => $member,
|
||||||
|
'form' => $form->createView()
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ class HouseholdMember
|
|||||||
return $this->endDate;
|
return $this->endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEndDate(\DateTimeImmutable $endDate): self
|
public function setEndDate(?\DateTimeImmutable $endDate = null): self
|
||||||
{
|
{
|
||||||
$this->endDate = $endDate;
|
$this->endDate = $endDate;
|
||||||
|
|
||||||
|
@ -77,6 +77,11 @@ class Position
|
|||||||
return $this->allowHolder;
|
return $this->allowHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAllowHolder(): ?bool
|
||||||
|
{
|
||||||
|
return $this->getAllowHolder();
|
||||||
|
}
|
||||||
|
|
||||||
public function setAllowHolder(bool $allowHolder): self
|
public function setAllowHolder(bool $allowHolder): self
|
||||||
{
|
{
|
||||||
$this->allowHolder = $allowHolder;
|
$this->allowHolder = $allowHolder;
|
||||||
|
42
src/Bundle/ChillPersonBundle/Form/HouseholdMemberType.php
Normal file
42
src/Bundle/ChillPersonBundle/Form/HouseholdMemberType.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Form;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
class HouseholdMemberType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('startDate', ChillDateType::class, [
|
||||||
|
'label' => 'household.Start date',
|
||||||
|
'input' => 'datetime_immutable',
|
||||||
|
])
|
||||||
|
->add('endDate', ChillDateType::class, [
|
||||||
|
'label' => 'household.End date',
|
||||||
|
'input' => 'datetime_immutable',
|
||||||
|
'required' => false
|
||||||
|
])
|
||||||
|
;
|
||||||
|
if ($options['data']->getPosition()->isAllowHolder()) {
|
||||||
|
$builder
|
||||||
|
->add('holder', ChoiceType::class, [
|
||||||
|
'label' => 'household.holder',
|
||||||
|
'choices' => [
|
||||||
|
'household.is holder' => true,
|
||||||
|
'household.is not holder' => false
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$builder
|
||||||
|
->add('comment', ChillTextareaType::class, [
|
||||||
|
'label' => 'household.Comment'
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
{% extends '@ChillPerson/Household/layout.html.twig' %}
|
||||||
|
|
||||||
|
{% block title 'household.Edit member household'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_widget(form) }}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a
|
||||||
|
href="{{ chill_return_path_or('chill_person_household_members', { 'household_id': household.id}) }}"
|
||||||
|
class="sc-button bt-cancel"
|
||||||
|
>
|
||||||
|
{{ 'Cancel'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="submit" class="sc-button bt-save">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -5,7 +5,7 @@
|
|||||||
<div class="grid-6">{% set title = title %}
|
<div class="grid-6">{% set title = title %}
|
||||||
<h1>
|
<h1>
|
||||||
<i class="fa fa-child"></i>
|
<i class="fa fa-child"></i>
|
||||||
{{ 'Household'|trans }}
|
{{ 'household.Household'|trans }}
|
||||||
<span style="font-weight: lighter; font-size: 50%;">(n°{{ household.id }})</span>
|
<span style="font-weight: lighter; font-size: 50%;">(n°{{ household.id }})</span>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
{% extends '@ChillPerson/Household/layout.html.twig' %}
|
{% extends '@ChillPerson/Household/layout.html.twig' %}
|
||||||
|
|
||||||
{% block title 'Household members'|trans %}
|
{% block title 'household.Household members'|trans %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ block('title') }}</h1>
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
<p>Household with id {{ household.id }}</p>
|
|
||||||
|
|
||||||
{% for p in positions %}
|
{% for p in positions %}
|
||||||
<h3>{{ p.label|localize_translatable_string }}</h3>
|
<h3>{{ p.label|localize_translatable_string }}</h3>
|
||||||
|
|
||||||
@ -22,9 +20,9 @@
|
|||||||
<div class="item-row person">
|
<div class="item-row person">
|
||||||
<div class="item-col box-person">
|
<div class="item-col box-person">
|
||||||
<div>
|
<div>
|
||||||
{{ m.person|chill_entity_render_box }}
|
{{ m.person|chill_entity_render_box({'addLink': true}) }}
|
||||||
{% if m.holder %}
|
{% if m.holder %}
|
||||||
<span class="badge badge-primary">{{ 'Holder'|trans }}</span>
|
<span class="badge badge-primary">{{ 'household.holder'|trans }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -40,12 +38,25 @@
|
|||||||
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path('chill_person_household_member_edit', { 'id': m.id }) }}"
|
||||||
|
class="sc-button bt-edit"
|
||||||
|
/>
|
||||||
|
{{ 'household.Update membership'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#" class="sc-button" /><i class="fa fa-sign-out"></i>{{ 'household.Leave'|trans }}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if m.comment is not empty %}
|
{% if m.comment is not empty %}
|
||||||
<div class="item-row comment">
|
<div class="item-row comment">
|
||||||
<blockquote class="chill-user-quote">
|
<blockquote class="chill-user-quote">
|
||||||
{{ m.comment }}
|
{{ m.comment|chill_markdown_to_html }}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -53,7 +64,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="chill-no-data-statement">{{ 'Any persons into this position'|trans }}</p>
|
<p class="chill-no-data-statement">{{ 'household.Any persons into this position'|trans }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% set members = household.nonCurrentMembersByPosition(p) %}
|
{% set members = household.nonCurrentMembersByPosition(p) %}
|
||||||
@ -70,9 +81,9 @@
|
|||||||
<div class="item-row person">
|
<div class="item-row person">
|
||||||
<div class="item-col box-person">
|
<div class="item-col box-person">
|
||||||
<div>
|
<div>
|
||||||
{{ m.person|chill_entity_render_box }}
|
{{ m.person|chill_entity_render_box({'addLink': true}) }}
|
||||||
{% if m.holder %}
|
{% if m.holder %}
|
||||||
<span class="badge badge-primary">{{ 'Holder'|trans }}</span>
|
<span class="badge badge-primary">{{ 'household.holder'|trans }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -88,16 +99,27 @@
|
|||||||
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path('chill_person_household_member_edit', { 'id': m.id }) }}"
|
||||||
|
class="sc-button bt-edit"
|
||||||
|
/>
|
||||||
|
{{ 'household.Update membership'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if m.comment is not empty %}
|
{% if m.comment is not empty %}
|
||||||
<div class="item-row comment">
|
<div class="item-row comment">
|
||||||
<blockquote class="chill-user-quote">
|
<blockquote class="chill-user-quote">
|
||||||
{{ m.comment }}
|
{{ m.comment|chill_markdown_to_html }}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,3 +62,8 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
resource: '../Repository/'
|
resource: '../Repository/'
|
||||||
tags: ['doctrine.repository_service']
|
tags: ['doctrine.repository_service']
|
||||||
|
|
||||||
|
Chill\PersonBundle\Controller\:
|
||||||
|
autowire: true
|
||||||
|
resource: '../Controller/'
|
||||||
|
tags: ['controller.service_arguments']
|
||||||
|
@ -6,6 +6,8 @@ Born the date: >-
|
|||||||
}
|
}
|
||||||
|
|
||||||
household:
|
household:
|
||||||
|
Household: Ménage
|
||||||
|
Household members: Membres du ménage
|
||||||
Show future or past memberships: >-
|
Show future or past memberships: >-
|
||||||
{length, plural,
|
{length, plural,
|
||||||
one {Montrer une ancienne appartenance}
|
one {Montrer une ancienne appartenance}
|
||||||
@ -13,4 +15,15 @@ household:
|
|||||||
other {Montrer # anciennes ou futures appartenances}
|
other {Montrer # anciennes ou futures appartenances}
|
||||||
}
|
}
|
||||||
Those members does not share address: Ces usagers ne partagent pas l'adresse du ménage.
|
Those members does not share address: Ces usagers ne partagent pas l'adresse du ménage.
|
||||||
|
Any persons into this position: Aucune personne n'appartient au ménage à cette position.
|
||||||
|
Leave: Quitter le ménage
|
||||||
|
Update membership: Modifier
|
||||||
|
successfully saved member: Membre enregistré avec succès
|
||||||
|
Start date: Date de début de l'appartenance au ménage
|
||||||
|
End date: Date de fin de l'appartenance au ménage
|
||||||
|
Comment: Commentaire
|
||||||
|
is holder: Est titulaire
|
||||||
|
is not holder: N'est pas titulaire
|
||||||
|
holder: Titulaire
|
||||||
|
Edit member household: Modifier l'appartenance au ménage
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user