From ac4c82129093d37c6fe840e1224e037e64bddff1 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 20:08:04 +0100 Subject: [PATCH 1/8] FEATURE [profession] change field type of profession into string --- .../Entity/ThirdParty.php | 13 ++++----- .../migrations/Version20230215175150.php | 29 +++++++++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 src/Bundle/ChillThirdPartyBundle/migrations/Version20230215175150.php diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 2e8cebfb6..43f053c77 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -250,14 +250,11 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * [fr] Qualité. - * - * @var ThirdPartyProfession - * @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession") - * ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true) + * @ORM\Column(name="profession", type="string", length=255, nullable=false) * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) * @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"}) */ - private ?ThirdPartyProfession $profession = null; + private string $profession = ''; /** * @ORM\Column(name="telephone", type="phone_number", nullable=true) @@ -491,9 +488,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface } /** - * @return ThirdPartyProfession + * @return string */ - public function getProfession(): ?ThirdPartyProfession + public function getProfession(): string { return $this->profession; } @@ -811,7 +808,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @return $this */ - public function setProfession(?ThirdPartyProfession $profession): ThirdParty + public function setProfession(string $profession): self { $this->profession = $profession; diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20230215175150.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20230215175150.php new file mode 100644 index 000000000..b87e722b4 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20230215175150.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_3party.third_party ADD profession VARCHAR(255) DEFAULT \'\' NOT NULL'); + +// $this->addSql('ALTER TABLE chill_3party.third_party DROP profession_id'); + } + + public function down(Schema $schema): void + { +// $this->addSql('ALTER TABLE chill_3party.third_party ADD profession_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_3party.third_party DROP profession'); + } +} From bea839663f022736f4292f92c40ee72c903f6c60 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Feb 2023 20:08:53 +0100 Subject: [PATCH 2/8] FEATURE [form] adjust symfony form to use text type --- .../ChillThirdPartyBundle/Form/ThirdPartyType.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 79f107575..384c743c2 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -20,14 +20,10 @@ use Chill\MainBundle\Form\Type\PickCivilityType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\ThirdPartyBundle\Entity\ThirdParty; -use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession; use Chill\ThirdPartyBundle\Form\Type\PickThirdPartyTypeCategoryType; use Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter; use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\QueryBuilder; -use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; @@ -111,17 +107,8 @@ class ThirdPartyType extends AbstractType 'placeholder' => 'thirdparty.choose civility', 'required' => false, ]) - ->add('profession', EntityType::class, [ + ->add('profession', TextType::class, [ 'label' => 'thirdparty.Profession', - 'class' => ThirdPartyProfession::class, - 'choice_label' => function (ThirdPartyProfession $profession): string { - return $this->translatableStringHelper->localize($profession->getName()); - }, - 'query_builder' => static function (EntityRepository $er): QueryBuilder { - return $er->createQueryBuilder('p') - ->where('p.active = true'); - }, - 'placeholder' => 'thirdparty.choose profession', 'required' => false, ]) ->add('contactDataAnonymous', CheckboxType::class, [ From e50b02a8c7c73c030ca07a493fa3aa9a2946e5ce Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 Feb 2023 17:56:28 +0100 Subject: [PATCH 3/8] FIX [rendering] adjust vue components to correctly render profession string --- .../public/vuejs/_components/AddPersons/TypeThirdParty.vue | 2 +- .../public/vuejs/_components/Entity/ThirdPartyRenderBox.vue | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue index 0c8251e4a..7fb77226d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons/TypeThirdParty.vue @@ -1,7 +1,7 @@