mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'features/household-members-list' into features/household-editor
This commit is contained in:
commit
18217f53e8
@ -171,7 +171,7 @@ class HouseholdMemberController extends ApiController
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/api/1.0/person/household/member/{id}/edit",
|
||||
* "/{_locale}/person/household/member/{id}/edit",
|
||||
* name="chill_person_household_member_edit"
|
||||
* )
|
||||
*/
|
||||
|
@ -98,7 +98,7 @@ class Household
|
||||
return $this->members;
|
||||
}
|
||||
|
||||
public function getCurrentMembers(\DateTimeImmutable $now = null): Collection
|
||||
public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$expr = Criteria::expr();
|
||||
@ -118,6 +118,19 @@ class Household
|
||||
return $this->getMembers()->matching($criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the persons currently associated to the household.
|
||||
*
|
||||
* Return a list of Person, instead of a list of HouseholdMembers
|
||||
*
|
||||
* @return Person[]
|
||||
*/
|
||||
public function getCurrentPersons(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getCurrentMembers($now)
|
||||
->map(function(HouseholdMember $m) { return $m->getPerson(); });
|
||||
}
|
||||
|
||||
public function getNonCurrentMembers(\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
|
@ -1,5 +1,7 @@
|
||||
/// complete and overwrite flex-table in chillmain.scss
|
||||
div.list-with-period {
|
||||
div.list-with-period,
|
||||
div.list-household-members,
|
||||
div.list-household-members--summary {
|
||||
div.person {
|
||||
ul.record_actions {
|
||||
li {
|
||||
@ -7,6 +9,9 @@ div.list-with-period {
|
||||
}
|
||||
}
|
||||
}
|
||||
div.comment {
|
||||
// for the comment for household-members
|
||||
}
|
||||
div.periods {
|
||||
div.header,
|
||||
div.list-content {
|
||||
@ -39,12 +44,14 @@ div.list-with-period {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chill-entity__person {
|
||||
.chill-entity__person__first-name,
|
||||
.chill-entity__person__last-name {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chill-entity__person {
|
||||
.chill-entity__person__first-name,
|
||||
.chill-entity__person__last-name {
|
||||
font-size: 1.3em;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,11 @@
|
||||
{%- for n in person.altNames -%}
|
||||
{%- if loop.first -%}({% else %} {%- endif -%}
|
||||
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
|
||||
{{ n.label }}
|
||||
{{- n.label -}}
|
||||
</span>
|
||||
{%- if loop.last %}) {% endif -%}
|
||||
{%- if loop.last -%}) {%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- if showLink is defined -%}</a>{%- endif -%}</span>
|
||||
{%- if showLink is defined -%}</a>{%- endif -%}
|
||||
{#- tricks to remove easily whitespace after template -#}
|
||||
{%- if true -%}</span>{%- endif -%}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div class="subheader">
|
||||
<div class="subheader banner-household">
|
||||
<div class="grid-12 parent" id="header-accompanying_course-name" >
|
||||
<div class="grid-10 push-1 grid-mobile-12 grid-tablet-12 push-mobile-0 push-tablet-0 parent">
|
||||
|
||||
@ -18,9 +18,23 @@
|
||||
</div>
|
||||
<div class="grid-12 parent" id="header-accompanying_course-details" >
|
||||
<div class="grid-10 push-1 grid-mobile-12 grid-tablet-12 push-mobile-0 push-tablet-0 parent">
|
||||
|
||||
<div id="banner-misc"></div>
|
||||
|
||||
<div id="banner-misc">
|
||||
{%- set persons = household.getCurrentPersons() -%}
|
||||
{%- if persons|length > 0 -%}
|
||||
<span class="current-members-explain">
|
||||
{{- 'household.Current household members'|trans }}:
|
||||
</span>
|
||||
{%- for p in persons|slice(0, 5) -%}
|
||||
{{- p|chill_entity_render_box({'addLink': false}) -}}
|
||||
{%- if false == loop.last -%}, {% endif -%}
|
||||
{%- endfor -%}
|
||||
{% if persons|length > 5 %}
|
||||
<span class="current-members-more">
|
||||
{{ 'household.and x other persons'|trans({'x': persons|length-5}) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{%- endif -%}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
{%- set members = household.currentMembersByPosition(p) %}
|
||||
{% if members|length > 0 %}
|
||||
<div class="household-list-members flex-table list-with-period">
|
||||
<div class="flex-table list-household-members">
|
||||
{% for m in members %}
|
||||
<div class="item-bloc">
|
||||
<div class="item-row person">
|
||||
@ -75,7 +75,7 @@
|
||||
</button>
|
||||
|
||||
<div id="nonCurrent_{{ p.id }}" class="collapse">
|
||||
<div class="household-list-members flex-table list-with-period">
|
||||
<div class="flex-table list-household-members">
|
||||
{% for m in members %}
|
||||
<div class="item-bloc">
|
||||
<div class="item-row person">
|
||||
@ -127,5 +127,12 @@
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li>
|
||||
<a class="sc-button bt-create">
|
||||
{{ 'household.Add a member'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -16,7 +16,7 @@
|
||||
<p>{{ 'household.Those members does not share address'|trans }}</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="household-list-members flex-table list-with-period">
|
||||
<div class="flex-table list-household-members--summary">
|
||||
{% for m in members %}
|
||||
<div class="item-bloc">
|
||||
<div class="item-row person">
|
||||
|
@ -8,6 +8,7 @@ use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
@ -17,7 +18,7 @@ class HouseholdMemberControllerTest extends WebTestCase
|
||||
use PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidData
|
||||
* @dataProvider provideValidDataMove
|
||||
*/
|
||||
public function testMoveMember($personId, $householdId, $positionId, \DateTimeInterface $date)
|
||||
{
|
||||
@ -66,7 +67,31 @@ class HouseholdMemberControllerTest extends WebTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function provideValidData(): \Iterator
|
||||
/**
|
||||
* @dataProvider provideValidDataEditMember
|
||||
*/
|
||||
public function testEditMember($memberId)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$crawler = $client->request(
|
||||
Request::METHOD_GET,
|
||||
"/fr/person/household/member/{$memberId}/edit"
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
$form['household_member[endDate]'] = (new \DateTime('tomorrow'))
|
||||
->format('d-m-Y');
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function provideValidDataMove(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
@ -95,4 +120,22 @@ class HouseholdMemberControllerTest extends WebTestCase
|
||||
new \DateTimeImmutable('today')
|
||||
];
|
||||
}
|
||||
|
||||
public function provideValidDataEditMember(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$membershipIds = $em->createQuery("SELECT m.id FROM ".HouseholdMember::class." m ".
|
||||
"JOIN m.person p ".
|
||||
"JOIN p.center c ".
|
||||
"WHERE c.name = :center AND m.endDate IS NULL")
|
||||
->setParameter('center', 'Center A')
|
||||
->getScalarResult()
|
||||
;
|
||||
|
||||
\shuffle($membershipIds);
|
||||
|
||||
yield [ \array_pop($membershipIds)['id'] ];
|
||||
}
|
||||
}
|
||||
|
@ -29,3 +29,9 @@ household:
|
||||
Current household members: Membres actuels du ménage
|
||||
Household summary: Résumé
|
||||
Addresses: Adresses
|
||||
and x other persons: >-
|
||||
{x, plural,
|
||||
one {et une autre personne}
|
||||
many {et # autres personnes}
|
||||
other {et # autres personnes}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8e74ea90b1376e25f837c582965d1e549e5c485b
|
||||
Subproject commit eb7d6397f301efc388060c24165db24d349c9402
|
Loading…
x
Reference in New Issue
Block a user