mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
remove members page, move to summary
This commit is contained in:
parent
f1120af59e
commit
0add757230
@ -13,6 +13,7 @@ use Symfony\Component\Translation\TranslatorInterface;
|
|||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
|
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{_locale}/person/household")
|
* @Route("/{_locale}/person/household")
|
||||||
@ -21,12 +22,13 @@ class HouseholdController extends AbstractController
|
|||||||
{
|
{
|
||||||
private TranslatorInterface $translator;
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
/**
|
private PositionRepository $positionRepository;
|
||||||
* @param TranslatorInterface $translator
|
|
||||||
*/
|
public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository)
|
||||||
public function __construct(TranslatorInterface $translator)
|
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
$this->positionRepository = $positionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,9 +43,8 @@ class HouseholdController extends AbstractController
|
|||||||
{
|
{
|
||||||
// TODO ACL
|
// TODO ACL
|
||||||
|
|
||||||
$positions = $this->getDoctrine()->getManager()
|
$positions = $this->positionRepository
|
||||||
->getRepository(Position::class)
|
->findByActiveOrdered()
|
||||||
->findAll()
|
|
||||||
;
|
;
|
||||||
|
|
||||||
// little performance improvement:
|
// little performance improvement:
|
||||||
@ -58,42 +59,6 @@ class HouseholdController extends AbstractController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/members",
|
|
||||||
* name="chill_person_household_members",
|
|
||||||
* methods={"GET", "HEAD"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function members(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
$positions = $this->getDoctrine()->getManager()
|
|
||||||
->getRepository(Position::class)
|
|
||||||
->findAll()
|
|
||||||
;
|
|
||||||
|
|
||||||
// little performance improvement:
|
|
||||||
// initialize members collection, which will avoid
|
|
||||||
// some queries
|
|
||||||
$household->getMembers()->initialize();
|
|
||||||
|
|
||||||
if ($request->query->has('edit')) {
|
|
||||||
$form = $this->createMetadataForm($household);
|
|
||||||
} else {
|
|
||||||
$form = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/members.html.twig',
|
|
||||||
[
|
|
||||||
'household' => $household,
|
|
||||||
'positions' => $positions,
|
|
||||||
'form' => NULL !== $form ? $form->createView(): $form
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/{household_id}/addresses",
|
* "/{household_id}/addresses",
|
||||||
|
@ -35,13 +35,6 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'household_id' => $household->getId()
|
'household_id' => $household->getId()
|
||||||
]])
|
]])
|
||||||
->setExtras(['order' => 10]);
|
->setExtras(['order' => 10]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Household members'), [
|
|
||||||
'route' => 'chill_person_household_members',
|
|
||||||
'routeParameters' => [
|
|
||||||
'household_id' => $household->getId()
|
|
||||||
]])
|
|
||||||
->setExtras(['order' => 20]);
|
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('household.Addresses'), [
|
$menu->addChild($this->translator->trans('household.Addresses'), [
|
||||||
'route' => 'chill_person_household_addresses',
|
'route' => 'chill_person_household_addresses',
|
||||||
|
@ -7,14 +7,9 @@ use Chill\PersonBundle\Entity\Household\Position;
|
|||||||
//use Doctrine\Persistence\ManagerRegistry;
|
//use Doctrine\Persistence\ManagerRegistry;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\Persistence\ObjectRepository;
|
||||||
|
|
||||||
/**
|
final class PositionRepository implements ObjectRepository
|
||||||
* @method Position|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method Position|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method Position[] findAll()
|
|
||||||
* @method Position[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
final class PositionRepository
|
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
|
||||||
@ -30,4 +25,45 @@ final class PositionRepository
|
|||||||
{
|
{
|
||||||
return $this->repository->findAll();
|
return $this->repository->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Position[]
|
||||||
|
*/
|
||||||
|
public function findByActiveOrdered(): array
|
||||||
|
{
|
||||||
|
return $this->repository->createQueryBuilder('p')
|
||||||
|
->select('p')
|
||||||
|
->orderBy('p.ordering', 'ASC')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Position[]
|
||||||
|
*/
|
||||||
|
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||||
|
{
|
||||||
|
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Position[]
|
||||||
|
*/
|
||||||
|
public function findOneBy(array $criteria): array
|
||||||
|
{
|
||||||
|
return $this->repository->findOneBy($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Position
|
||||||
|
*/
|
||||||
|
public function find($id)
|
||||||
|
{
|
||||||
|
return $this->repository->find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClassName()
|
||||||
|
{
|
||||||
|
return Position::class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/// complete and overwrite flex-table in chillmain.scss
|
/// complete and overwrite flex-table in chillmain.scss
|
||||||
div.list-with-period,
|
div.list-with-period,
|
||||||
div.list-household-members,
|
div.list-household-members {
|
||||||
div.list-household-members--summary {
|
|
||||||
|
|
||||||
.chill-entity__person {
|
.chill-entity__person {
|
||||||
.chill-entity__person__first-name,
|
.chill-entity__person__first-name,
|
||||||
|
@ -5,49 +5,174 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ block('title') }}</h1>
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
<h2>{{ 'household.Current household members'|trans }}</h2>
|
<h2>{{ 'household.Current address'|trans }}</h2>
|
||||||
|
|
||||||
|
{% set address = household.currentAddress %}
|
||||||
|
|
||||||
|
{% if address is empty %}
|
||||||
|
<p class="chill-no-data-statement">{{ 'household.Household does not have any address currently'|trans }}</p>
|
||||||
|
{% else %}
|
||||||
|
<div>
|
||||||
|
{{ address|chill_entity_render_box({'multiline': true}) }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h2>{{ 'household.Household members'|trans }}</h2>
|
||||||
|
|
||||||
{% for p in positions %}
|
{% for p in positions %}
|
||||||
{%- set members = household.currentMembersByPosition(p) %}
|
<h3>{{ p.label|localize_translatable_string }}</h3>
|
||||||
{% if members|length > 0 %}
|
|
||||||
<h3>{{ p.label|localize_translatable_string }}</h3>
|
|
||||||
|
|
||||||
{% if false == p.shareHousehold %}
|
{% if false == p.shareHousehold %}
|
||||||
<p>{{ 'household.Those members does not share address'|trans }}</p>
|
<p>{{ 'household.Those members does not share address'|trans }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="flex-table list-household-members--summary">
|
{%- set members = household.currentMembersByPosition(p) %}
|
||||||
{% for m in members %}
|
{% if members|length > 0 %}
|
||||||
<div class="item-bloc">
|
<div class="flex-table list-household-members">
|
||||||
<div class="item-row person">
|
{% for m in members %}
|
||||||
<div class="item-col box-person">
|
<div class="item-bloc">
|
||||||
<div>
|
<div class="item-row person">
|
||||||
{{ m.person|chill_entity_render_box({'addLink': true}) }}
|
<div class="item-col box-person">
|
||||||
{% if m.holder %}
|
<div>
|
||||||
<span class="badge badge-primary">{{ 'household.holder'|trans }}</span>
|
{{ m.person|chill_entity_render_box({'addLink': true}) }}
|
||||||
|
{% if m.holder %}
|
||||||
|
<span class="badge badge-primary">{{ 'household.holder'|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="item-col box-where">
|
||||||
|
<ul class="list-content fa-ul">
|
||||||
|
{% if m.startDate is not empty %}
|
||||||
|
<li>{{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if m.endDate is not empty %}
|
||||||
|
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
||||||
|
{% endif %}
|
||||||
|
</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="{{ chill_path_add_return_path(
|
||||||
|
'chill_person_household_members_editor',
|
||||||
|
{
|
||||||
|
'persons': [ m.person.id ],
|
||||||
|
'household': household.id
|
||||||
|
} ) }}"
|
||||||
|
class="sc-button"
|
||||||
|
/>
|
||||||
|
<i class="fa fa-arrows-h"></i>
|
||||||
|
{{ 'household.Change position'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path(
|
||||||
|
'chill_person_household_members_editor',
|
||||||
|
{
|
||||||
|
'persons': [ m.person.id ],
|
||||||
|
'allow_leave_without_household': true
|
||||||
|
} ) }}"
|
||||||
|
class="sc-button"
|
||||||
|
/>
|
||||||
|
<i class="fa fa-sign-out"></i>
|
||||||
|
{{ 'household.Leave'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if m.comment is not empty %}
|
||||||
|
<div class="item-row comment">
|
||||||
|
<blockquote class="chill-user-quote">
|
||||||
|
{{ m.comment|chill_markdown_to_html }}
|
||||||
|
</blockquote>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
{% endfor %}
|
||||||
{{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }}
|
</div>
|
||||||
</div>
|
{% else %}
|
||||||
</div>
|
<p class="chill-no-data-statement">{{ 'household.Any persons into this position'|trans }}</p>
|
||||||
<div class="item-col box-where">
|
{% endif %}
|
||||||
<ul class="list-content fa-ul">
|
|
||||||
{% if m.startDate is not empty %}
|
{% set members = household.nonCurrentMembersByPosition(p) %}
|
||||||
<li>{{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}</li>
|
{% if members|length > 0 %}
|
||||||
{% endif %}
|
<p><!-- force a space after table --></p>
|
||||||
{% if m.endDate is not empty %}
|
<button class="sc-button bt-green" type="button" data-toggle="collapse" data-target="#nonCurrent_{{ p.id }}" aria-expanded="false" aria-controls="collapse non current members">
|
||||||
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
{{ 'household.Show future or past memberships'|trans({'length': members|length}) }}
|
||||||
{% endif %}
|
</button>
|
||||||
</ul>
|
|
||||||
|
<div id="nonCurrent_{{ p.id }}" class="collapse">
|
||||||
|
<div class="flex-table list-household-members">
|
||||||
|
{% for m in members %}
|
||||||
|
<div class="item-bloc">
|
||||||
|
<div class="item-row person">
|
||||||
|
<div class="item-col box-person">
|
||||||
|
<div>
|
||||||
|
{{ m.person|chill_entity_render_box({'addLink': true}) }}
|
||||||
|
{% if m.holder %}
|
||||||
|
<span class="badge badge-primary">{{ 'household.holder'|trans }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="item-col box-where">
|
||||||
|
<ul class="list-content fa-ul">
|
||||||
|
{% if m.startDate is not empty %}
|
||||||
|
<li>{{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if m.endDate is not empty %}
|
||||||
|
<li>{{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}</li>
|
||||||
|
{% endif %}
|
||||||
|
</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>
|
||||||
|
{% if m.comment is not empty %}
|
||||||
|
<div class="item-row comment">
|
||||||
|
<blockquote class="chill-user-quote">
|
||||||
|
{{ m.comment|chill_markdown_to_html }}
|
||||||
|
</blockquote>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path('chill_person_household_members_editor', {'household': household.id }) }}"
|
||||||
|
class="sc-button bt-create">
|
||||||
|
{{ 'household.Add a member'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -23,6 +23,7 @@ household:
|
|||||||
Any persons into this position: Aucune personne n'appartient au ménage à cette position.
|
Any persons into this position: Aucune personne n'appartient au ménage à cette position.
|
||||||
Leave: Quitter le ménage
|
Leave: Quitter le ménage
|
||||||
Join: Rejoindre un ménage
|
Join: Rejoindre un ménage
|
||||||
|
Change position: Repositionner
|
||||||
Household file: Dossier ménage
|
Household file: Dossier ménage
|
||||||
Add a member: Ajouter un membre
|
Add a member: Ajouter un membre
|
||||||
Update membership: Modifier
|
Update membership: Modifier
|
||||||
@ -37,6 +38,8 @@ household:
|
|||||||
Current household members: Membres actuels du ménage
|
Current household members: Membres actuels du ménage
|
||||||
Household summary: Résumé
|
Household summary: Résumé
|
||||||
Addresses: Adresses
|
Addresses: Adresses
|
||||||
|
Current address: Adresse actuelle
|
||||||
|
Household does not have any address currently: Le ménage n'a pas d'adresse renseignée actuellement
|
||||||
Edit household members: Modifier l'appartenance au ménage
|
Edit household members: Modifier l'appartenance au ménage
|
||||||
and x other persons: >-
|
and x other persons: >-
|
||||||
{x, plural,
|
{x, plural,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user