diff --git a/CHANGELOG.md b/CHANGELOG.md index 577cb99cf..71b72e2b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to * Household: show date validFrom and validTo when moving * address reference: add index for refid * [accompanyingCourse_work] fix styles conflicts + fix bug with remove goal (remove goals one at a time) +* [accompanyingCourse] improve masonry on resume page, add origin ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php b/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php index ae291067b..7226e96c9 100644 --- a/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php +++ b/src/Bundle/ChillPersonBundle/Config/ConfigPersonAltNamesHelper.php @@ -11,8 +11,6 @@ declare(strict_types=1); namespace Chill\PersonBundle\Config; -use function count; - /** * Give help to interact with the config for alt names. */ @@ -69,6 +67,6 @@ class ConfigPersonAltNamesHelper */ public function hasAltNames(): bool { - return count($this->config) > 0; + return [] !== $this->config; } } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 813ccee2a..5be598426 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -15,15 +15,14 @@ use Chill\MainBundle\CRUD\Controller\ApiController; use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; - -use function array_filter; -use function array_values; +use function in_array; class PersonApiController extends ApiController { @@ -56,8 +55,10 @@ class PersonApiController extends ApiController static fn (array $data, string $key): array => ['key' => $key, 'labels' => $data], $configAltNamesChoices, array_keys($configAltNamesChoices) - ), - Response::HTTP_OK, [], ['groups' => ['read']] + ), + Response::HTTP_OK, + [], + ['groups' => ['read']] ); } @@ -79,23 +80,51 @@ class PersonApiController extends ApiController { $this->denyAccessUnlessGranted(PersonVoter::SEE, $person); - $addresses = []; + $seenAddressIds = []; + // collect addresses from location in courses - foreach ($person->getAccompanyingPeriodParticipations() as $participation) { - if (null !== $participation->getAccompanyingPeriod()->getAddressLocation()) { - $a = $participation->getAccompanyingPeriod()->getAddressLocation(); - $addresses[$a->getId()] = $a; - } - } + $addresses = $person + ->getAccompanyingPeriodParticipations() + ->filter( + static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): bool { + return null !== $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation(); + } + ) + ->map( + static function (AccompanyingPeriodParticipation $accompanyingPeriodParticipation): ?Address { + return $accompanyingPeriodParticipation->getAccompanyingPeriod()->getAddressLocation(); + } + ) + ->filter( + // We remove potential null addresses. + static fn (?Address $address): bool => null !== $address + ) + ->filter( + static function (Address $address) use (&$seenAddressIds): bool { + $id = $address->getId(); + + if (in_array($id, $seenAddressIds, true)) { + return false; + } + + $seenAddressIds[] = $id; + + return true; + } + ); // remove the actual address $actual = $person->getCurrentHouseholdAddress(); if (null !== $actual) { - $addresses = array_filter($addresses, static fn ($a) => $a !== $actual); + $addresses = $addresses->filter(static fn (Address $address): bool => $address !== $actual); } - return $this->json(array_values($addresses), Response::HTTP_OK, [], ['groups' => ['read']]); + return $this->json( + $addresses->getValues(), + Response::HTTP_OK, + [], + ['groups' => ['read']] + ); } - } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss index f39f64eb2..db5df905a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/chillperson.scss @@ -254,3 +254,24 @@ abbr.referrer { // still used ? border: 1px solid black; padding: 10px; } + +/// Masonry blocs on AccompanyingCourse resume page +div#dashboards { + div.mbloc { + & > div:not(.warnings) { + border: 1px solid $chill-light-gray; + background-color: $chill-llight-gray; + border-radius: 0.35rem; + padding: 1rem; + } + & > div.warnings .alert { + margin-bottom: 0; + } + blockquote.chill-user-quote { + margin: -1.2em; + p { + margin: 0; + } + } + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index 39e924d18..fe7cd53c4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -21,104 +21,134 @@ {% block content %}
-
+
+ {% if 'DRAFT' == accompanyingCourse.step %} -
- {% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %} +
+
+ {% include '@ChillPerson/AccompanyingCourse/_still_draft.html.twig' %} +
{% endif %} {% if 'DRAFT' != accompanyingCourse.step %} {% if withoutHousehold|length > 0 %} -
- {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %} +
+
+ {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' %} +
{% endif %} {% endif %} {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} -
- {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %} +
+
+ {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' %} +
{% endif %} -
- {% if accompanyingCourse.locationStatus == 'person' %} -

{{ 'This course is located by'|trans }}

-

{{ accompanyingCourse.personLocation|chill_entity_render_string }}

- {% elseif accompanyingCourse.locationStatus == 'address' %} -

{{ 'This course has a temporarily location'|trans }}

- {% endif %} +
+
+ {% if accompanyingCourse.locationStatus == 'person' %} +

{{ 'This course is located by'|trans }}

+

{{ accompanyingCourse.personLocation|chill_entity_render_string }}

+ {% elseif accompanyingCourse.locationStatus == 'address' %} +

{{ 'This course has a temporarily location'|trans }}

+ {% endif %} - {% if accompanyingCourse.locationStatus != 'none' %} - {{ accompanyingCourse.location|chill_entity_render_box }} - {% endif %} + {% if accompanyingCourse.locationStatus != 'none' %} + {{ accompanyingCourse.location|chill_entity_render_box }} + {% endif %} +
- {% if accompanyingCourse.participations is not empty %} -
-

{{ 'Persons associated'|trans }}

- {% for r in accompanyingCourse.participations %} - {{ _self.insert_onthefly('person', r.person) }} - {% endfor %} -
- {% endif %} - - {% if accompanyingCourse.resources is not empty %} -
-

{{ 'Resources'|trans }}

- {% for r in accompanyingCourse.resources %} - {% if r.person is not null %} - {{ _self.insert_onthefly('person', r.person) }} - {% elseif r.thirdParty is not null %} - {{ _self.insert_onthefly('thirdparty', r.thirdParty) }} - {% endif %} - {% endfor %} -
- {% endif %} - {% if accompanyingCourse.pinnedComment is not empty %} -
-

{{ 'Pinned comment'|trans }}

-
- {{ accompanyingCourse.pinnedComment.content }} -
+
{% endif %} - {% if accompanyingCourse.scopes is not empty %} -
-

{{ 'Scopes'|trans }}

-
- {% for s in accompanyingCourse.scopes %} - {{ s.name|localize_translatable_string|capitalize }}{% if not loop.last %}, {% endif %} + {% if accompanyingCourse.participations is not empty %} +
+
+

{{ 'Persons associated'|trans }}

+ {% for r in accompanyingCourse.participations %} + {{ _self.insert_onthefly('person', r.person) }} {% endfor %}
{% endif %} - {% if accompanyingCourse.requestorPerson is not null or accompanyingCourse.requestorThirdParty is not null %} -
- {% if accompanyingCourse.requestorPerson is not null %} -

{{ 'Requestor'|trans }}

- {{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }} - {% elseif accompanyingCourse.requestorThirdParty is not null %} -

{{ 'Requestor'|trans }}

- {{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }} - {% endif %} + {% if accompanyingCourse.resources is not empty %} +
+
+

{{ 'Resources'|trans }}

+ {% for r in accompanyingCourse.resources %} + {% if r.person is not null %} + {{ _self.insert_onthefly('person', r.person) }} + {% elseif r.thirdParty is not null %} + {{ _self.insert_onthefly('thirdparty', r.thirdParty) }} + {% endif %} + {% endfor %} +
{% endif %} + + {% if accompanyingCourse.scopes is not empty %} +
+
+

{{ 'Scopes'|trans }}

+
+ {% for s in accompanyingCourse.scopes %} + {{ s.name|localize_translatable_string|capitalize }}{% if not loop.last %}, {% endif %} + {% endfor %} +
+
+
+ {% endif %} + + {% if accompanyingCourse.requestorPerson is not null or accompanyingCourse.requestorThirdParty is not null %} +
+
+ {% if accompanyingCourse.requestorPerson is not null %} +

{{ 'Requestor'|trans }}

+ {{ _self.insert_onthefly('person', accompanyingCourse.requestorPerson) }} + {% elseif accompanyingCourse.requestorThirdParty is not null %} +

{{ 'Requestor'|trans }}

+ {{ _self.insert_onthefly('thirdparty', accompanyingCourse.requestorThirdParty) }} + {% endif %} +
+
+ {% endif %} + + {% if accompanyingCourse.origin is not empty %} +
+
+

{{ 'Origin'|trans }}

+ {{ accompanyingCourse.origin.label|localize_translatable_string|capitalize }} +
+
+ {% endif %} +