From 349db2142defe9cc6845e8ca7e7244997740da37 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 14:39:00 +0100 Subject: [PATCH 1/9] person: add url field to SocialWork Evaluation entity + populate with http title values --- .../Entity/SocialWork/Evaluation.php | 18 +++++++++ .../migrations/Version20220303113855.php | 38 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php 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/migrations/Version20220303113855.php b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php new file mode 100644 index 000000000..9991d2eca --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE chill_person_social_work_evaluation ADD url TEXT DEFAULT NULL'); + $this->addSql("UPDATE chill_person_social_work_evaluation SET url = CASE WHEN title->>'fr' LIKE 'http%' THEN title->>'fr' ELSE null END;"); + } + + public function down(Schema $schema): void + { + + $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP url'); + } +} From 568a1d95f46544fff7040710359b5fd7ea91a634 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 15:10:05 +0100 Subject: [PATCH 2/9] AccompanyingCourseWorkEdit: add url to vuejs form --- .../components/AddEvaluation.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 }} + +
@@ -128,4 +133,11 @@ export default { } } } + div.item-url { + i { + color: unset!important; + margin-left: 1rem; + margin-right: 0.5rem; + } + } From a88e052eb64f06c4195f9a3b20f319ac291505d3 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 15:12:47 +0100 Subject: [PATCH 3/9] upd CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd743078..7de2c188a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to ## Unreleased +* [person] Add url in accompanying period work evaluations entity and form (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/476) + + * [parcours] Toggle emergency/intensity only by referrer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/442) * [docstore] Add an API entrypoint for StoredObject (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) * [person] Add the possibility of uploading existing documents to AccPeriodWorkEvaluationDocument (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/466) From c5eac09478e1b9bed3369182ce351f64420a0366 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 3 Mar 2022 15:17:05 +0100 Subject: [PATCH 4/9] php cs fix on migration --- .../migrations/Version20220303113855.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php index 9991d2eca..7840cdfce 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220303113855.php @@ -15,10 +15,15 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Add url to SocialWork Evaluation + * Add url to SocialWork Evaluation. */ final class Version20220303113855 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP url'); + } + public function getDescription(): string { return 'Add url to SocialWork Evaluation'; @@ -29,10 +34,4 @@ final class Version20220303113855 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD url TEXT DEFAULT NULL'); $this->addSql("UPDATE chill_person_social_work_evaluation SET url = CASE WHEN title->>'fr' LIKE 'http%' THEN title->>'fr' ELSE null END;"); } - - public function down(Schema $schema): void - { - - $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP url'); - } } From e9236875d223129a67a498b7006f35d9a36e59c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Mar 2022 15:44:30 +0100 Subject: [PATCH 5/9] quick fix for phonenumber alt on person --- src/Bundle/ChillPersonBundle/Entity/PersonPhone.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 400e39c88..f33646f09 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; } @@ -115,7 +116,7 @@ class PersonPhone $this->person = $person; } - public function setPhonenumber(string $phonenumber): void + public function setPhonenumber(?PhoneNumber $phonenumber): void { $this->phonenumber = $phonenumber; } From d0772fc306d4f9e95774b3631fa3ac6fcfdd0897 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 4 Mar 2022 17:08:41 +0100 Subject: [PATCH 6/9] Add email to twig personRenderBox --- CHANGELOG.md | 1 + .../Resources/views/Entity/person.html.twig | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a38f2ea47..380cc6afe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,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/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig index 9ffdbfae6..e7eac0b34 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig @@ -167,6 +167,18 @@ {{ 'No data given'|trans }} {% endif %} + {% if person.email is not null %} +
  • + + {{ person.email }} + +
  • + {% else %} +
  • + + {{ 'No data given'|trans }} +
  • + {% endif %} {% if options['addCenter'] and person|chill_resolve_center|length > 0 %}
  • From 44ed2e44e0e9d446972032cc51c96618d5316693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 6 Mar 2022 22:10:54 +0100 Subject: [PATCH 7/9] another way to fix phonenumber and telephone in third party / OnTheFly --- .../Serializer/Normalizer/PhonenumberNormalizer.php | 4 ++++ .../components/Resources/ResourceItem.vue | 4 +++- .../vuejs/_components/Entity/ThirdPartyRenderBox.vue | 8 ++++---- .../public/vuejs/_components/OnTheFly/ThirdParty.vue | 2 +- .../Serializer/Normalizer/ThirdPartyNormalizer.php | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) 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/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/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue index 1555ec66a..bcdbf5e55 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/Entity/ThirdPartyRenderBox.vue @@ -61,9 +61,9 @@
  • -
  • +
  • - {{ thirdparty.phonenumber }} + {{ thirdparty.telephone }}
  • @@ -78,9 +78,9 @@
  • -
  • +
  • - {{ thirdparty.phonenumber }} + {{ thirdparty.telephone }}
  • diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 40efa9bfb..8de41b989 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -118,7 +118,7 @@
    diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index 65bc15ba0..8e4775aad 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -62,7 +62,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf }, $thirdParty->getTypesAndCategories()), 'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context), 'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']), - 'phonenumber' => $this->normalizer->normalize($thirdParty->getTelephone()), + 'telephone' => $this->normalizer->normalize($thirdParty->getTelephone()), 'email' => $thirdParty->getEmail(), 'isChild' => $thirdParty->isChild(), 'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context), From 03471a74fedc0ac451d8ceb395e14308df1bf509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 6 Mar 2022 22:28:33 +0100 Subject: [PATCH 8/9] fix creating alt phonenumber --- .../Phonenumber/PhoneNumberHelperInterface.php | 2 +- .../Phonenumber/PhonenumberHelper.php | 13 +++++++++++-- src/Bundle/ChillPersonBundle/Entity/PersonPhone.php | 3 ++- src/Bundle/ChillPersonBundle/Form/PersonType.php | 3 ++- .../ChillPersonBundle/Form/Type/PersonPhoneType.php | 3 ++- 5 files changed, 18 insertions(+), 6 deletions(-) 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..8fdaf2596 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,17 @@ 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/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index f33646f09..7d0bce1ff 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -98,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 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..1910d4605 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php @@ -11,6 +11,7 @@ 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; @@ -36,7 +37,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, ]); From 7afada5dad29d34a981baf5c60ff8955e6b3a2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 6 Mar 2022 22:36:38 +0100 Subject: [PATCH 9/9] fix cs --- src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php | 2 ++ src/Bundle/ChillPersonBundle/Entity/PersonPhone.php | 2 +- src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index 8fdaf2596..22f580d78 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -92,9 +92,11 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface 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/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 7d0bce1ff..7f0e28ddb 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -98,7 +98,7 @@ class PersonPhone public function isEmpty(): bool { - return ("" === $this->getDescription() || null === $this->getDescription()) + return ('' === $this->getDescription() || null === $this->getDescription()) && null === $this->getPhonenumber(); } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php index 1910d4605..3b1de28c7 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PersonPhoneType.php @@ -16,7 +16,6 @@ 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;