diff --git a/CHANGELOG.md b/CHANGELOG.md index d760a8b6a..89f8867a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,7 @@ and this project adheres to * [main] filter user job in undispatch acc period to assign (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/472) - - +* [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) * [person] Add document generation in admin and in person/{id}/document (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/464) * [activity] do not override location if already exist (when validating new activity) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/470) * [parcours] Toggle emergency/intensity only by referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) @@ -31,6 +30,7 @@ and this project adheres to * [confidential] Fix position of toggle button so it does not cover text nor fall outside of box (no issue) * [parcours] Fix edit of both thirdparty and contact name (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/474) * [template] do not list inactive templates (for doc generator) +* [person] email added to twig personRenderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/490) ## Test releases diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php b/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php index eeab9c38d..1ed67d967 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhoneNumberHelperInterface.php @@ -27,7 +27,7 @@ interface PhoneNumberHelperInterface /** * Get type (mobile, landline, ...) for phone number. */ - public function getType(string $phonenumber): string; + public function getType(PhoneNumber $phonenumber): string; /** * Return true if the validation is configured and available. diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index c73b3dc95..22f580d78 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -17,6 +17,7 @@ use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\ServerException; use libphonenumber\NumberParseException; use libphonenumber\PhoneNumber; +use libphonenumber\PhoneNumberType; use libphonenumber\PhoneNumberUtil; use Psr\Cache\CacheItemPoolInterface; use Psr\Log\LoggerInterface; @@ -86,9 +87,19 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface /** * Get type (mobile, landline, ...) for phone number. */ - public function getType(string $phonenumber): string + public function getType(PhoneNumber $phonenumber): string { - return $this->performTwilioLookup($phonenumber) ?? 'unknown'; + switch ($this->phoneNumberUtil->getNumberType($phonenumber)) { + case PhoneNumberType::MOBILE: + return 'mobile'; + + case PhoneNumberType::FIXED_LINE: + case PhoneNumberType::VOIP: + return 'landline'; + + default: + return 'landline'; + } } /** diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php index cb59e6421..3562c1361 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/PhonenumberNormalizer.php @@ -40,6 +40,10 @@ class PhonenumberNormalizer implements NormalizerInterface, DenormalizerInterfac */ public function denormalize($data, $type, $format = null, array $context = []) { + if ('' === trim($data)) { + return null; + } + try { return $this->phoneNumberUtil->parse($data, $this->defaultCarrierCode); } catch (NumberParseException $e) { diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 400e39c88..7f0e28ddb 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Entity; use DateTime; use Doctrine\ORM\Mapping as ORM; +use libphonenumber\PhoneNumber; /** * Person Phones. @@ -51,9 +52,9 @@ class PersonPhone private Person $person; /** - * @ORM\Column(type="text", length=40, nullable=false) + * @ORM\Column(type="phone_number", nullable=false) */ - private string $phonenumber = ''; + private ?PhoneNumber $phonenumber = null; /** * @ORM\Column(type="text", length=40, nullable=true) @@ -85,7 +86,7 @@ class PersonPhone return $this->person; } - public function getPhonenumber(): string + public function getPhonenumber(): ?PhoneNumber { return $this->phonenumber; } @@ -97,7 +98,8 @@ class PersonPhone public function isEmpty(): bool { - return empty($this->getDescription()) && empty($this->getPhonenumber()); + return ('' === $this->getDescription() || null === $this->getDescription()) + && null === $this->getPhonenumber(); } public function setDate(DateTime $date): void @@ -115,7 +117,7 @@ class PersonPhone $this->person = $person; } - public function setPhonenumber(string $phonenumber): void + public function setPhonenumber(?PhoneNumber $phonenumber): void { $this->phonenumber = $phonenumber; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php index 1350ae6d8..9349c335e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php @@ -62,6 +62,12 @@ class Evaluation */ private array $title = []; + /** + * @ORM\Column(type="text", nullable=true) + * @Serializer\Groups({"read", "docgen:read"}) + */ + private ?string $url = null; + public function __construct() { $this->socialActions = new ArrayCollection(); @@ -101,6 +107,11 @@ class Evaluation return $this->title; } + public function getUrl(): ?string + { + return $this->url; + } + public function removeSocialAction(SocialAction $socialAction): self { if ($this->socialActions->contains($socialAction)) { @@ -130,4 +141,11 @@ class Evaluation return $this; } + + public function setUrl(?string $url): self + { + $this->url = $url; + + return $this; + } } diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index acc65c6ac..68ebd3ef4 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -27,6 +27,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\PersonPhone; use Chill\PersonBundle\Form\Type\GenderType; use Chill\PersonBundle\Form\Type\PersonAltNameType; +use Chill\PersonBundle\Form\Type\PersonPhoneType; use Chill\PersonBundle\Form\Type\Select2MaritalStatusType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; @@ -158,7 +159,7 @@ class PersonType extends AbstractType } $builder->add('otherPhoneNumbers', ChillCollectionType::class, [ - 'entry_type' => ChillPhoneNumberType::class, + 'entry_type' => PersonPhoneType::class, 'button_add_label' => 'Add new phone', 'button_remove_label' => 'Remove phone', 'required' => false, diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php index 00243349f..3b1de28c7 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php @@ -11,11 +11,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\Form\Type; +use Chill\MainBundle\Form\Type\ChillPhoneNumberType; use Chill\MainBundle\Phonenumber\PhonenumberHelper; use Chill\PersonBundle\Entity\PersonPhone; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; @@ -36,7 +36,7 @@ class PersonPhoneType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('phonenumber', TelType::class, [ + $builder->add('phonenumber', ChillPhoneNumberType::class, [ 'label' => 'Other phonenumber', 'required' => true, ]); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue index 8d897da13..37321e0bb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue @@ -170,7 +170,9 @@ export default { console.log('data', payload.data) body.name = payload.data.name; body.email = payload.data.email; - body.telephone = payload.data.phonenumber; + body.telephone = payload.data.telephone; + body.civility = payload.data.civility; + body.profession = payload.data.profession; body.address = payload.data.address ? { id: payload.data.address.address_id } : null; makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue index 579d0b306..d2b8c5b46 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/components/AddEvaluation.vue @@ -5,6 +5,11 @@ {{ evaluation.evaluation.title.fr }} +
+