mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'issue439_residential_address_otf' into 'master'
residential address in OnTheFly See merge request Chill-Projet/chill-bundles!350
This commit is contained in:
commit
d50d68aa86
@ -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)
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Rename residential_address table.
|
||||
*/
|
||||
final class Version20220217133607 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->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;');
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
@ -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
|
||||
// */
|
@ -128,6 +128,52 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-col mx-3" v-if="this.showResidentialAddresses && (person.current_residential_addresses || []).length > 0">
|
||||
<div class="float-button bottom">
|
||||
<div class="box" >
|
||||
<ul class="list-content fa-ul">
|
||||
<li v-for="(addr, i) in person.current_residential_addresses" :key="i">
|
||||
<i class="fa fa-li fa-map-marker"></i>
|
||||
<div v-if="addr.address">
|
||||
<address-render-box
|
||||
:address="addr.address"
|
||||
:isMultiline="isMultiline">
|
||||
</address-render-box>
|
||||
<p>({{ $t('renderbox.residential_address') }})</p>
|
||||
</div>
|
||||
<div v-else-if="addr.hostPerson" class="mt-3">
|
||||
<p>{{ $t('renderbox.located_at') }}:</p>
|
||||
<span class="chill-entity entity-person badge-person">
|
||||
<person-text
|
||||
v-if="addr.hostPerson"
|
||||
:person="addr.hostPerson"
|
||||
></person-text>
|
||||
</span>
|
||||
<address-render-box v-if="addr.hostPerson.address"
|
||||
:address="addr.hostPerson.address"
|
||||
:isMultiline="isMultiline">
|
||||
</address-render-box>
|
||||
</div>
|
||||
<div v-else-if="addr.hostThirdParty" class="mt-3">
|
||||
<p>{{ $t('renderbox.located_at') }}:</p>
|
||||
<span class="chill-entity entity-person badge-thirdparty">
|
||||
<third-party-text
|
||||
v-if="addr.hostThirdParty"
|
||||
:thirdparty="addr.hostThirdParty"
|
||||
></third-party-text>
|
||||
</span>
|
||||
<address-render-box v-if="addr.hostThirdParty.address"
|
||||
:address="addr.hostThirdParty.address"
|
||||
:isMultiline="isMultiline">
|
||||
</address-render-box>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@ -159,6 +205,7 @@ import AddressRenderBox from 'ChillMainAssets/vuejs/_components/Entity/AddressRe
|
||||
import Confidential from 'ChillMainAssets/vuejs/_components/Confidential.vue';
|
||||
import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue';
|
||||
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
||||
import ThirdPartyText from 'ChillThirdPartyAssets/vuejs/_components/Entity/ThirdPartyText.vue';
|
||||
|
||||
export default {
|
||||
name: "PersonRenderBox",
|
||||
@ -166,9 +213,28 @@ export default {
|
||||
AddressRenderBox,
|
||||
Confidential,
|
||||
BadgeEntity,
|
||||
PersonText
|
||||
PersonText,
|
||||
ThirdPartyText
|
||||
},
|
||||
props: {
|
||||
person: {
|
||||
required: true,
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
required: false,
|
||||
},
|
||||
render: {
|
||||
type: String,
|
||||
},
|
||||
returnPath: {
|
||||
type: String,
|
||||
},
|
||||
showResidentialAddresses: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
props: ['person', 'options', 'render', 'returnPath'],
|
||||
computed: {
|
||||
isMultiline: function() {
|
||||
if(this.options.isMultiline){
|
||||
|
@ -15,6 +15,7 @@
|
||||
addNoData: true,
|
||||
isMultiline: true
|
||||
}"
|
||||
:show-residential-addresses="true"
|
||||
></person-render-box>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -62,7 +62,7 @@
|
||||
<li>
|
||||
<i class="fa fa-li fa-home"></i>
|
||||
<span class="item-key">{{ "Address of"|trans}}</span>
|
||||
<span class="chill-entity entity-person badge-person">{{ a.hostThirdParty|chill_entity_render_box }}</span>
|
||||
<span class="chill-entity entity-person badge-thirdparty">{{ a.hostThirdParty|chill_entity_render_box }}</span>
|
||||
</li>
|
||||
<li>
|
||||
{% if a.hostThirdParty.address is not null %}
|
||||
|
@ -18,11 +18,13 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderExtension;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonAltName;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
@ -49,15 +51,19 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
|
||||
private PersonRepository $repository;
|
||||
|
||||
private ResidentialAddressRepository $residentialAddressRepository;
|
||||
|
||||
public function __construct(
|
||||
ChillEntityRenderExtension $render,
|
||||
PersonRepository $repository,
|
||||
CenterResolverManagerInterface $centerResolverManager,
|
||||
ResidentialAddressRepository $residentialAddressRepository,
|
||||
PhoneNumberHelperInterface $phoneNumberHelper
|
||||
) {
|
||||
$this->render = $render;
|
||||
$this->repository = $repository;
|
||||
$this->centerResolverManager = $centerResolverManager;
|
||||
$this->residentialAddressRepository = $residentialAddressRepository;
|
||||
$this->phoneNumberHelper = $phoneNumberHelper;
|
||||
}
|
||||
|
||||
@ -180,27 +186,39 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
|
||||
*/
|
||||
public function normalize($person, $format = null, array $context = [])
|
||||
{
|
||||
$groups = $context[AbstractNormalizer::GROUPS] ?? [];
|
||||
$household = $person->getCurrentHousehold();
|
||||
$currentResidentialAddresses = $this->residentialAddressRepository->findCurrentResidentialAddressByPerson($person);
|
||||
|
||||
return [
|
||||
$data = [
|
||||
'type' => 'person',
|
||||
'id' => $person->getId(),
|
||||
'text' => $this->render->renderString($person, ['addAge' => false]),
|
||||
'textAge' => $this->render->renderString($person, ['addAge' => true]),
|
||||
'firstName' => $person->getFirstName(),
|
||||
'lastName' => $person->getLastName(),
|
||||
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress(), $format, $context),
|
||||
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context),
|
||||
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context),
|
||||
'age' => $this->normalizer->normalize($person->getAge(), $format, $context),
|
||||
'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context),
|
||||
'phonenumber' => $this->normalizer->normalize($person->getPhonenumber()),
|
||||
'mobilenumber' => $this->normalizer->normalize($person->getMobilenumber()),
|
||||
'email' => $person->getEmail(),
|
||||
'altNames' => $this->normalizeAltNames($person->getAltNames()),
|
||||
'gender' => $person->getGender(),
|
||||
'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress(), $format, $context),
|
||||
'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null,
|
||||
];
|
||||
|
||||
if (in_array("minimal", $groups) && 1 === count($groups)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return array_merge($data, [
|
||||
'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context),
|
||||
'altNames' => $this->normalizeAltNames($person->getAltNames()),
|
||||
'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null,
|
||||
'current_residential_addresses' => $currentResidentialAddresses ?
|
||||
$this->normalizer->normalize($currentResidentialAddresses, $format, $context) :
|
||||
null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function supportsDenormalization($data, $type, $format = null)
|
||||
|
@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<span v-if="isCut">{{ cutText }}</span>
|
||||
<span v-else class="thirdparty-text">
|
||||
<span class="firstname">{{ thirdparty.text }}</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "ThirdPartyText",
|
||||
props: {
|
||||
thirdparty: {
|
||||
required: true,
|
||||
},
|
||||
isCut: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
cutText: function() {
|
||||
let more = (this.thirdparty.text.length > 15) ?'…' : '';
|
||||
return this.thirdparty.text.slice(0,15) + more;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user