diff --git a/CHANGELOG.md b/CHANGELOG.md index 7637230db..3bd743078 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to * [Person/Household list] when listing other simultaneous members of an household, exclude the members on person, not on members (avoid to show two membersship with the same person) * [draft periods] add a delete button (if acl granted) on each draft period listed on draft period page (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/463) * [Person] Display suffixText in RenderPerson, PersonText.vue, RenderPersonBox.vue (was made for displaying "enfant confie") (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/441) +* [person] residential address: show residential address or info in PersonRenderBox, refactor Residential Address (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/439) +* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) * [documents] Improve flex-table item-col placement when long buttons and long metadata * [thirdparty] Fix display of multiple contact badges so they wrap onto next line (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/482) * [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) @@ -39,7 +41,6 @@ and this project adheres to * [person]: AddPersons: add suggestion of name when creating new person or thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422) * [main] Address: fix small bug: when modifying an address without street (isNoAddress), also check errors if street is an empty string as back-end change null value to empty string for street (and streetNumber) * [main] Address: stronger client-side validation of addresses (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/449) -* [thirdparty] Add a contact to a thirdparty from within onTheFly (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/345) * [person] accompanying course: filter suggested entities by open participations (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/415) [activity] can click through the cross icon for removing person in concerned group (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/476) [activity] correct associated persons by considering only open participations (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/476) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js index 00ae02dc8..6ae44be41 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js @@ -70,7 +70,8 @@ const messages = { }, holder: "Titulaire", years_old: "an | {n} an | {n} ans", - + residential_address: "Adresse de résidence", + located_at: "réside chez" } } }; diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php b/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php new file mode 100644 index 000000000..b6c6106f1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20220217133607.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE IF EXISTS chill_person_residential_address RENAME TO chill_main_residential_address;'); + $this->addSql('ALTER SEQUENCE IF EXISTS chill_person_residential_address_id_seq RENAME TO chill_main_residential_address_id_seq;'); + } + + public function getDescription(): string + { + return 'Rename residential_address table'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE IF EXISTS chill_main_residential_address RENAME TO chill_person_residential_address;'); + $this->addSql('ALTER SEQUENCE IF EXISTS chill_main_residential_address_id_seq RENAME TO chill_person_residential_address_id_seq;'); + } +} diff --git a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php index 8b266208a..f77a4150c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ResidentialAddressController.php @@ -11,10 +11,10 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; -use Chill\MainBundle\Entity\ResidentialAddress; -use Chill\MainBundle\Form\Type\ResidentialAddressType; -use Chill\MainBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Entity\Person\ResidentialAddress; +use Chill\PersonBundle\Form\Type\ResidentialAddressType; +use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\Extension\Core\Type\FormType; diff --git a/src/Bundle/ChillMainBundle/Entity/ResidentialAddress.php b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php similarity index 87% rename from src/Bundle/ChillMainBundle/Entity/ResidentialAddress.php rename to src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php index 7763ea9d5..cb82f766a 100644 --- a/src/Bundle/ChillMainBundle/Entity/ResidentialAddress.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/ResidentialAddress.php @@ -9,24 +9,28 @@ declare(strict_types=1); -namespace Chill\MainBundle\Entity; +namespace Chill\PersonBundle\Entity\Person; +use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; -use Chill\MainBundle\Repository\ResidentialAddressRepository; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Chill\ThirdPartyBundle\Entity\ThirdParty; use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Annotation\Context; /** * @ORM\Entity(repositoryClass=ResidentialAddressRepository::class) - * @ORM\Table(name="chill_main_residential_address") + * @ORM\Table(name="chill_person_residential_address") */ class ResidentialAddress { /** * @ORM\ManyToOne(targetEntity=Address::class) * @ORM\JoinColumn(nullable=true) + * @Groups({"read"}) */ private ?Address $address = null; @@ -37,18 +41,22 @@ class ResidentialAddress /** * @ORM\Column(type="datetime_immutable", nullable=true) + * @Groups({"read"}) */ private ?DateTimeImmutable $endDate = null; /** * @ORM\ManyToOne(targetEntity=Person::class) * @ORM\JoinColumn(nullable=true) + * @Groups({"read"}) + * @Context(normalizationContext={"groups"={"minimal"}}) */ private ?Person $hostPerson = null; /** * @ORM\ManyToOne(targetEntity=ThirdParty::class) * @ORM\JoinColumn(nullable=true) + * @Groups({"read"}) */ private ?ThirdParty $hostThirdParty = null; @@ -67,6 +75,7 @@ class ResidentialAddress /** * @ORM\Column(type="datetime_immutable") + * @Groups({"read"}) */ private ?DateTimeImmutable $startDate = null; diff --git a/src/Bundle/ChillMainBundle/Form/Type/ResidentialAddressType.php b/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php similarity index 91% rename from src/Bundle/ChillMainBundle/Form/Type/ResidentialAddressType.php rename to src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php index 0ebe47fef..b34395daf 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ResidentialAddressType.php +++ b/src/Bundle/ChillPersonBundle/Form/ResidentialAddressType.php @@ -9,10 +9,11 @@ declare(strict_types=1); -namespace Chill\MainBundle\Form\Type; +namespace Chill\PersonBundle\Form\Type; -use Chill\MainBundle\Entity\ResidentialAddress; -use Chill\PersonBundle\Form\Type\PickPersonDynamicType; +use Chill\MainBundle\Form\Type\CommentType; +use Chill\MainBundle\Form\Type\PickAddressType; +use Chill\PersonBundle\Entity\Person\ResidentialAddress; use Chill\ThirdPartyBundle\Form\Type\PickThirdpartyDynamicType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\DateType; diff --git a/src/Bundle/ChillMainBundle/Repository/ResidentialAddressRepository.php b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php similarity index 54% rename from src/Bundle/ChillMainBundle/Repository/ResidentialAddressRepository.php rename to src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php index 05cdfdf6c..b5d64a31a 100644 --- a/src/Bundle/ChillMainBundle/Repository/ResidentialAddressRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/ResidentialAddressRepository.php @@ -9,10 +9,14 @@ declare(strict_types=1); -namespace Chill\MainBundle\Repository; +namespace Chill\PersonBundle\Repository; -use Chill\MainBundle\Entity\ResidentialAddress; +use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Entity\Person\ResidentialAddress; +use DateTimeImmutable; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ManagerRegistry; /** @@ -28,6 +32,43 @@ class ResidentialAddressRepository extends ServiceEntityRepository parent::__construct($registry, ResidentialAddress::class); } + /** + * @param Person $person + * @param DateTimeImmutable|null $at + * @return array|ResidentialAddress[]|null + */ + public function findCurrentResidentialAddressByPerson(Person $person, ?DateTimeImmutable $at = null): array + { + return $this->buildQueryFindCurrentResidentialAddresses($person, $at) + ->select('ra') + ->getQuery() + ->getResult(); + } + + public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder + { + $date = null === $at ? new DateTimeImmutable('today') : $at; + $qb = $this->createQueryBuilder('ra'); + + + + $dateFilter = $qb->expr()->andX( + $qb->expr()->lte('ra.startDate', ':dateIn'), + $qb->expr()->orX( + $qb->expr()->isNull('ra.endDate'), + $qb->expr()->gte('ra.endDate', ':dateIn') + ) + ); + + $qb + ->where($dateFilter) + ->setParameter('dateIn', $date, Types::DATE_IMMUTABLE) + ->andWhere('ra.person = :person') + ->setParameter('person', $person); + + return $qb; + } + // /** // * @return ResidentialAddress[] Returns an array of ResidentialAddress objects // */ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index f77f006db..f2cf1f7bd 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -126,7 +126,53 @@ + + +