diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d2bf9bb3..5c1dcb1f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,7 +52,11 @@ and this project adheres to * [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496) * [person_resource] separate create page created to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/504) * [contact] add contact button color changed plus the pipe at the side removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/506) +<<<<<<< HEAD * [thirdparty] For contacts show current civility/profession in edit form + fix saving of edited information (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/491) +======= +* [thirdparty] add firstname field to thirdparty 'child' or 'contact' types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/508) +>>>>>>> issue508_thirdparty_firstname * [household] create-edit household composition placed in separate page to avoid confusion (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/505) * [blur] Improved positioning of toggle icon (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/486) * [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index 437b8be99..e053c8ae8 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -232,7 +232,9 @@ export default { } else { type = this.$refs.castNew.radioType; data = this.$refs.castNew.castDataByType(); - console.log(data) + data.civility = {type: 'chill_main_civility', id: data.civility.id}; + data.profession = {type: 'third_party_profession', id: data.profession.id}; + // console.log('onthefly data', data); } } else { throw 'error with object type'; 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 597be1ce1..dca57f113 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 @@ -167,6 +167,8 @@ export default { }) } else if (payload.type === 'thirdparty') { + // console.log('data', payload.data) + body.firstname = payload.data.firstname; body.name = payload.data.name; body.email = payload.data.email; body.telephone = payload.data.telephone; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 366ecd6b7..e6fa85902 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -24,11 +24,11 @@
@@ -43,11 +43,11 @@
@@ -62,10 +62,10 @@
@@ -125,9 +125,9 @@
- +
@@ -238,13 +238,13 @@ export default { checkErrors(e) { this.errors = []; if (!this.person.lastName) { - this.errors.push("Le nom ne doit pas être vide."); + this.errors.push("Le nom ne doit pas être vide."); } if (!this.person.firstName) { - this.errors.push("Le prénom ne doit pas être vide."); + this.errors.push("Le prénom ne doit pas être vide."); } if (!this.person.gender) { - this.errors.push("Le genre doit être renseigné"); + this.errors.push("Le genre doit être renseigné"); } }, loadData() { diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php index 124f5b7f3..d2023fae5 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php @@ -46,6 +46,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte $loader->load('services/fixtures.yaml'); $loader->load('services/serializer.yaml'); $loader->load('services/repository.yaml'); + $loader->load('services/doctrineEventListener.yaml'); } public function prepend(ContainerBuilder $container) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 678084045..fff378cdb 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -197,6 +197,12 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface */ private ?string $email = null; + /** + * @ORM\Column(name="firstname", type="string", length=255, nullable=true) + * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) + */ + private ?string $firstname = null; + /** * @var int * @ORM\Column(name="id", type="integer") @@ -454,12 +460,12 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->email; } - /** - * Get id. - * - * @return int - */ - public function getId() + public function getFirstname(): ?string + { + return $this->firstname; + } + + public function getId(): ?int { return $this->id; } @@ -469,12 +475,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->kind; } - /** - * Get name. - * - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } @@ -766,6 +767,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } + public function setFirstname($firstname): self + { + $this->firstname = $firstname; + + return $this; + } + public function setKind(?string $kind): ThirdParty { $this->kind = $kind; @@ -773,14 +781,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - /** - * Set name. - * - * @param string $name - * - * @return ThirdParty - */ - public function setName($name) + public function setName($name): self { $this->name = $name; diff --git a/src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php b/src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php new file mode 100644 index 000000000..bdeed8866 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php @@ -0,0 +1,31 @@ +getKind() !== 'company') { + $firstnameCaps = mb_convert_case(mb_strtolower($thirdparty->getFirstname()), MB_CASE_TITLE, 'UTF-8'); + $firstnameCaps = ucwords(strtolower($firstnameCaps), " \t\r\n\f\v'-"); + $thirdparty->setFirstName($firstnameCaps); + + $lastnameCaps = mb_strtoupper($thirdparty->getName(), 'UTF-8'); + $thirdparty->setName($lastnameCaps); + } + } +} diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index cf34c8919..242fa997b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -102,6 +102,10 @@ class ThirdPartyType extends AbstractType // Contact Person ThirdParty (child) if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) { $builder + ->add('firstname', TextType::class, [ + 'label' => 'firstname', + 'required' => false, + ]) ->add('civility', PickCivilityType::class, [ 'label' => 'thirdparty.Civility', 'placeholder' => 'thirdparty.choose civility', 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 5665457ac..86e569731 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -66,14 +66,14 @@
-
+
-
+
+
+
+
+ + +
+
+
    +
  • + {{ qi }} +
  • +
+
+
+
+
+ + +
+
+
    +
  • + {{ qi }} +
  • +
+
+
+
-
- - -
-
-
    -
  • - {{ query }} -
  • -
+
+
+ + +
+
+
    +
  • + {{ query }} +
  • +
+