diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php index 36d34677f..d0f93a05f 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdController.php @@ -13,6 +13,7 @@ use Symfony\Component\Translation\TranslatorInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\Position; +use Chill\PersonBundle\Repository\Household\PositionRepository; /** * @Route("/{_locale}/person/household") @@ -21,12 +22,13 @@ class HouseholdController extends AbstractController { private TranslatorInterface $translator; - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) + private PositionRepository $positionRepository; + + public function __construct(TranslatorInterface $translator, PositionRepository $positionRepository) + { $this->translator = $translator; + $this->positionRepository = $positionRepository; } /** @@ -41,9 +43,8 @@ class HouseholdController extends AbstractController { // TODO ACL - $positions = $this->getDoctrine()->getManager() - ->getRepository(Position::class) - ->findAll() + $positions = $this->positionRepository + ->findByActiveOrdered() ; // 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( * "/{household_id}/addresses", diff --git a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php index 3377b6f74..367a53890 100644 --- a/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/HouseholdMenuBuilder.php @@ -35,13 +35,6 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface 'household_id' => $household->getId() ]]) ->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'), [ 'route' => 'chill_person_household_addresses', diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php index a02de20dd..58a0995d6 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/PositionRepository.php @@ -7,14 +7,9 @@ use Chill\PersonBundle\Entity\Household\Position; //use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\Persistence\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 +final class PositionRepository implements ObjectRepository { private EntityRepository $repository; @@ -30,4 +25,45 @@ final class PositionRepository { 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; + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss b/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss index da37ab580..97c23c36a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss @@ -1,7 +1,6 @@ /// complete and overwrite flex-table in chillmain.scss div.list-with-period, -div.list-household-members, -div.list-household-members--summary { +div.list-household-members { .chill-entity__person { .chill-entity__person__first-name, diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig index 92fe1e6bc..95ac55b12 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig @@ -5,49 +5,174 @@ {% block content %}

{{ block('title') }}

-

{{ 'household.Current household members'|trans }}

+

{{ 'household.Current address'|trans }}

+ +{% set address = household.currentAddress %} + +{% if address is empty %} +

{{ 'household.Household does not have any address currently'|trans }}

+{% else %} +
+ {{ address|chill_entity_render_box({'multiline': true}) }} +
+{% endif %} + +

{{ 'household.Household members'|trans }}

{% for p in positions %} -{%- set members = household.currentMembersByPosition(p) %} -{% if members|length > 0 %} -

{{ p.label|localize_translatable_string }}

+

{{ p.label|localize_translatable_string }}

-{% if false == p.shareHousehold %} -

{{ 'household.Those members does not share address'|trans }}

-{% endif %} + {% if false == p.shareHousehold %} +

{{ 'household.Those members does not share address'|trans }}

+ {% endif %} -
- {% for m in members %} -
-
-
-
- {{ m.person|chill_entity_render_box({'addLink': true}) }} - {% if m.holder %} - {{ 'household.holder'|trans }} + {%- set members = household.currentMembersByPosition(p) %} + {% if members|length > 0 %} +
+ {% for m in members %} +
+
+
+
+ {{ m.person|chill_entity_render_box({'addLink': true}) }} + {% if m.holder %} + {{ 'household.holder'|trans }} + {% endif %} +
+
+ {{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }} +
+
+
+
    + {% if m.startDate is not empty %} +
  • {{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}
  • + {% endif %} + {% if m.endDate is not empty %} +
  • {{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}
  • + {% endif %} +
+ +
+
+ {% if m.comment is not empty %} +
+
+ {{ m.comment|chill_markdown_to_html }} +
+
{% endif %}
-
- {{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }} -
-
-
-
    - {% if m.startDate is not empty %} -
  • {{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}
  • - {% endif %} - {% if m.endDate is not empty %} -
  • {{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}
  • - {% endif %} -
+ {% endfor %} +
+ {% else %} +

{{ 'household.Any persons into this position'|trans }}

+ {% endif %} + + {% set members = household.nonCurrentMembersByPosition(p) %} + {% if members|length > 0 %} +

+ + +
+
+ {% for m in members %} +
+
+
+
+ {{ m.person|chill_entity_render_box({'addLink': true}) }} + {% if m.holder %} + {{ 'household.holder'|trans }} + {% endif %} +
+
+ {{ 'Born the date'|trans({ 'gender': m.person.gender, 'birthdate': m.person.birthdate|format_date('long') }) }} +
+
+
+
    + {% if m.startDate is not empty %} +
  • {{ 'Since %date%'|trans({'%date%': m.startDate|format_date('long') }) }}
  • + {% endif %} + {% if m.endDate is not empty %} +
  • {{ 'Until %date%'|trans({'%date%': m.endDate|format_date('long') }) }}
  • + {% endif %} +
+ +
+
+ {% if m.comment is not empty %} +
+
+ {{ m.comment|chill_markdown_to_html }} +
+
+ {% endif %} +
+ {% endfor %}
-
- {% endfor %} -
- -{% endif %} + {% endif %} {% endfor %} + + {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml index dcca83c40..f0d43ea5c 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml +++ b/src/Bundle/ChillPersonBundle/translations/messages+intl-icu.fr.yaml @@ -23,6 +23,7 @@ household: Any persons into this position: Aucune personne n'appartient au ménage à cette position. Leave: Quitter le ménage Join: Rejoindre un ménage + Change position: Repositionner Household file: Dossier ménage Add a member: Ajouter un membre Update membership: Modifier @@ -37,6 +38,8 @@ household: Current household members: Membres actuels du ménage Household summary: Résumé 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 and x other persons: >- {x, plural,