diff --git a/.changes/unreleased/Fixed-20230829-181332.yaml b/.changes/unreleased/Fixed-20230829-181332.yaml new file mode 100644 index 000000000..bf77afcf9 --- /dev/null +++ b/.changes/unreleased/Fixed-20230829-181332.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: '[household] when moving a person to a sharing position to a not-sharing position + on the same household on the same date, remove the previous household membership on the same household. This fix duplicate member.' +time: 2023-08-29T18:13:32.799479781+02:00 +custom: + Issue: "136" diff --git a/.changes/unreleased/Fixed-20230829-181837.yaml b/.changes/unreleased/Fixed-20230829-181837.yaml new file mode 100644 index 000000000..447e8379d --- /dev/null +++ b/.changes/unreleased/Fixed-20230829-181837.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: | + Add missing translation for comment field placeholder in repositionning household editor. +time: 2023-08-29T18:18:37.691526331+02:00 +custom: + Issue: "" diff --git a/.changes/unreleased/UX-20230829-181733.yaml b/.changes/unreleased/UX-20230829-181733.yaml new file mode 100644 index 000000000..981f2c272 --- /dev/null +++ b/.changes/unreleased/UX-20230829-181733.yaml @@ -0,0 +1,6 @@ +kind: UX +body: | + Uniformize badge-person in household banner (background, size) +time: 2023-08-29T18:17:33.190396543+02:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/Tests/Notification/Email/NotificationMailerTest.php b/src/Bundle/ChillMainBundle/Tests/Notification/Email/NotificationMailerTest.php index 19da87b79..c00804e0b 100644 --- a/src/Bundle/ChillMainBundle/Tests/Notification/Email/NotificationMailerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Notification/Email/NotificationMailerTest.php @@ -37,7 +37,6 @@ class NotificationMailerTest extends TestCase */ public function testPostPersistComment(): void { - $this->expectNotToPerformAssertions(); $user1 = (new User())->setEmail('user1@foo.com'); $user2 = (new User())->setEmail('user2@foo.com'); $user3 = (new User())->setEmail('user3@foo.com'); @@ -67,7 +66,7 @@ class NotificationMailerTest extends TestCase } return false; - })); + }))->shouldBeCalledTimes(2); $objectManager = $this->prophesize(EntityManagerInterface::class); @@ -77,7 +76,6 @@ class NotificationMailerTest extends TestCase public function testPostPersistCommentDestWithNullEmail(): void { - $this->expectNotToPerformAssertions(); $user1 = (new User())->setEmail('user1@foo.com'); $user2 = (new User())->setEmail('user2@foo.com'); $user3 = (new User())->setEmail(null); @@ -107,7 +105,7 @@ class NotificationMailerTest extends TestCase } return false; - })); + }))->shouldBeCalledTimes(1); $objectManager = $this->prophesize(EntityManagerInterface::class); diff --git a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php index 2b2564091..cc391c612 100644 --- a/src/Bundle/ChillPersonBundle/Household/MembersEditor.php +++ b/src/Bundle/ChillPersonBundle/Household/MembersEditor.php @@ -55,6 +55,14 @@ class MembersEditor $this->eventDispatcher = $eventDispatcher; } + /** + * Add a person to the household + * + * The person is added to the household associated with this editor's instance. + * + * If the person is also a member of another household, or the same household at the same position, the person + * is not associated any more with the previous household. + */ public function addMovement(DateTimeImmutable $date, Person $person, ?Position $position, ?bool $holder = false, ?string $comment = null): self { if (null === $this->household) { @@ -69,68 +77,66 @@ class MembersEditor ->setComment($comment); $this->household->addMember($membership); - if (null !== $position) { - if ($position->getShareHousehold()) { - // launch event only if moving to a "share household" position, - // and if the destination household is different than the previous one - $event = new PersonAddressMoveEvent($person); - $event->setNextMembership($membership); + if ($membership->getShareHousehold()) { + // launch event only if moving to a "share household" position, + // and if the destination household is different than the previous one + $event = new PersonAddressMoveEvent($person); + $event->setNextMembership($membership); - $counter = 0; + $counter = 0; - foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) { - if ($participation === $membership) { - continue; - } - - if ($participation->getStartDate() > $membership->getStartDate()) { - continue; - } - - ++$counter; - - if ($participation->getEndDate() === null || $participation->getEndDate() > $date) { - $participation->setEndDate($date); - $this->membershipsAffected[] = $participation; - $this->oldMembershipsHashes[] = spl_object_hash($participation); - - if ($participation->getHousehold() !== $this->household) { - $event->setPreviousMembership($participation); - $this->events[] = $event; - } - } + foreach ($person->getHouseholdParticipationsShareHousehold() as $participation) { + if ($participation === $membership) { + continue; } - // send also the event if there was no participation before - if (0 === $counter) { - $this->events[] = $event; + if ($participation->getStartDate() > $membership->getStartDate()) { + continue; } - foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) { - if ($participation->getHousehold() === $this->household - && $participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate() - && $participation->getStartDate() <= $membership->getStartDate() - ) { - $participation->setEndDate($membership->getStartDate()); + ++$counter; + + if ($participation->getEndDate() === null || $participation->getEndDate() > $date) { + $participation->setEndDate($date); + $this->membershipsAffected[] = $participation; + $this->oldMembershipsHashes[] = spl_object_hash($participation); + + if ($participation->getHousehold() !== $this->household) { + $event->setPreviousMembership($participation); + $this->events[] = $event; } } - } else { - // if a members is moved to the same household than the one he belongs to, - // we should make it leave the household - if ($person->getCurrentHousehold($date) === $this->household) { - $this->leaveMovement($date, $person); + } + + // send also the event if there was no participation before + if (0 === $counter) { + $this->events[] = $event; + } + + foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) { + if ($participation->getHousehold() === $this->household + && $participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate() + && $participation->getStartDate() <= $membership->getStartDate() + ) { + $participation->setEndDate($membership->getStartDate()); + } + } + } else { + // if there are multiple belongings not sharing household, close the others + foreach ($person->getHouseholdParticipations() as $participation) { + if ($participation === $membership) { + continue; } - // if there are multiple belongings not sharing household, close the others - foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) { - if ($participation === $membership) { - continue; - } - - if ($participation->getHousehold() === $this->household - && ($participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate()) - && $participation->getStartDate() <= $membership->getStartDate() - ) { + if ($participation->getHousehold() === $this->household + && ($participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate()) + && $participation->getStartDate() <= $membership->getStartDate() + ) { + if ($participation->getShareHousehold()) { + // if a members is moved to the same household than the one he belongs to, + // we should make it leave the household + $this->leaveMovement($date, $person); + } else { $participation->setEndDate($membership->getStartDate()); } } @@ -158,6 +164,15 @@ class MembersEditor return null !== $this->household; } + /** + * Makes a person leave the household. + * + * Makes a person leave the household **associated with this editor**. + * + * @param DateTimeImmutable $date + * @param Person $person + * @return $this + */ public function leaveMovement( DateTimeImmutable $date, Person $person @@ -167,8 +182,9 @@ class MembersEditor $criteria->where( $expr->andX( - $expr->lt('startDate', $date), - $expr->isNull('endDate') + $expr->lte('startDate', $date), + $expr->isNull('endDate'), + $expr->eq('shareHousehold', true) ) ); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss index 59a9b05db..24f947100 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss @@ -207,10 +207,11 @@ div.banner { span.badge-member { flex-shrink: 0; flex-grow: 0; flex-basis: auto; color: $white; + background-color: transparentize($white, 0.85); border: 1px solid transparentize($white, 0.75); border-bottom: 3px solid transparentize( shade-color( $chill-green, 20%), 0.3); border-radius: 8px; - padding: 0.2em 0.7em; + padding: 0.0em 0.5em; margin-bottom: 0.2em; margin-right: 0.3em; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/PersonComment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/PersonComment.vue index cb9a02d51..8f61a74d1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/PersonComment.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/PersonComment.vue @@ -1,7 +1,7 @@