From d5501bcfbdaddd3cfc7c0fc427972022916bea8d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Mar 2022 20:07:41 +0100 Subject: [PATCH 01/26] remove console logs to avoid mess in the console --- .../ChillMainBundle/Resources/public/lib/api/apiMethods.js | 3 --- .../Resources/public/vuejs/OnTheFly/components/OnTheFly.vue | 4 +--- .../public/vuejs/_components/Entity/AddressRenderBox.vue | 2 -- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js index 67f3e2f42..7bfd1071c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/apiMethods.js @@ -11,19 +11,16 @@ const makeFetch = (method, url, body) => { }) .then(response => { if (response.ok) { - console.log('200 error') return response.json(); } if (response.status === 422) { - console.log('422 error') return response.json().then(response => { throw ValidationException(response) }); } if (response.status === 403) { - console.log('403 error') throw AccessException(response); } 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 5528d563e..4ef6192f1 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -223,7 +223,7 @@ export default { default: if (typeof this.type === 'undefined') { // action=create or addContact - console.log('will rewrite data'); + console.log('will rewrite data'); if (this.action === 'addContact') { type = 'thirdparty' data = this.$refs.castThirdparty.$data.thirdparty; @@ -238,8 +238,6 @@ export default { throw 'error with object type'; } } - console.log('type', type); - console.log('data', data); // pass datas to parent this.$emit('saveFormOnTheFly', { type: type, data: data }); }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue index a7f121a87..2e88bc1cb 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/AddressRenderBox.vue @@ -89,11 +89,9 @@ export default { return this.isMultiline === true ? "div" : "span"; }, multiline() { - //console.log(this.isMultiline, typeof this.isMultiline); return this.isMultiline === true ? "multiline" : ""; }, isConfidential() { - console.log(this.address.confidential) return this.address.confidential; } } From ff4b90835e67ef9f9cdd71f2247a9d474e68d9b3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Mar 2022 20:29:38 +0100 Subject: [PATCH 02/26] show current civility and profession in edit form + fix saving of edited information --- .../public/vuejs/OnTheFly/components/OnTheFly.vue | 2 ++ .../components/Resources/ResourceItem.vue | 9 +++++---- .../public/vuejs/_components/OnTheFly/ThirdParty.vue | 10 ++++------ 3 files changed, 11 insertions(+), 10 deletions(-) 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 4ef6192f1..a04c68eaf 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -228,6 +228,8 @@ export default { type = 'thirdparty' data = this.$refs.castThirdparty.$data.thirdparty; console.log('data original', data); + data.civility = data.civility ? {type: 'chill_main_civility', id: data.civility.id} : null; + data.profession = data.profession ? {type: 'third_party_profession', id: data.profession.id} : null; data.parent = {type: "thirdparty", id: this.parent.id}; } else { type = this.$refs.castNew.radioType; 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 37321e0bb..597be1ce1 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 @@ -137,7 +137,7 @@ export default { }, methods: { saveFormOnTheFly(payload) { - console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data); + // console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data); payload.target = 'resource'; let body = { type: payload.type }; @@ -167,14 +167,15 @@ export default { }) } else if (payload.type === 'thirdparty') { - console.log('data', payload.data) body.name = payload.data.name; body.email = payload.data.email; body.telephone = payload.data.telephone; - body.civility = payload.data.civility; - body.profession = payload.data.profession; + body.civility = {type: 'chill_main_civility', id: payload.data.civility.id}; + body.profession = {type: 'third_party_profession', id: payload.data.profession.id}; body.address = payload.data.address ? { id: payload.data.address.address_id } : null; + console.log('body', body); + makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body) .then(response => { this.$store.dispatch('addThirdparty', { target: payload.target, body: response }) 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 8de41b989..6086d75c3 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -67,17 +67,17 @@
-
-
@@ -209,7 +209,6 @@ export default { context.addressId = this.thirdparty.address.address_id; context.edit = true; } - console.log('context', context); //this.context = context; <-- return context; }, @@ -219,7 +218,6 @@ export default { return getThirdparty(this.id).then(thirdparty => new Promise((resolve, reject) => { this.thirdparty = thirdparty; this.thirdparty.kind = thirdparty.kind; - console.log('get thirdparty', thirdparty); if (this.action !== 'show') { if (thirdparty.address !== null) { // bof! we force getInitialAddress because addressId not available when mounted From f79cfda74aa03605db26ba5cecf2e11ea71e40ac Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Mar 2022 20:31:02 +0100 Subject: [PATCH 03/26] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 885068bc0..be30846c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to * [thirdparty] Add parameter condition to display centers or not (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/500) * [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496) * [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) +* [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) ## Test releases From 00787adf2b2b93d492fe7912d77b26be716246e7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 09:35:22 +0100 Subject: [PATCH 04/26] firstname property added to thirdparty + canonicalize function adapted --- .../Entity/ThirdParty.php | 9 ++++++ .../migrations/Version20211007165001.php | 20 ++++++------ .../migrations/Version20220311133150.php | 31 +++++++++++++++++++ 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 678084045..db56dbd94 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -222,6 +222,15 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface */ private ?string $name = ''; + /** + * @ORM\Column(name="firstname", type="string", length=255) + * @Assert\Length(min="2") + * @Assert\NotNull + * @Assert\NotBlank + * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) + */ + private ?string $firstname = ''; + /** * [fr] Raison sociale. * diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20211007165001.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20211007165001.php index 2d33bbeb4..ef431f5ea 100644 --- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20211007165001.php +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20211007165001.php @@ -39,15 +39,17 @@ final class Version20211007165001 extends AbstractMigration $this->addSql(" UPDATE chill_3party.third_party SET canonicalized = - UNACCENT( - LOWER( - name || - CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(name_company, '') || - CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(acronym, '') - ) - ) + UNACCENT( + LOWER( + name || + CASE WHEN COALESCE (firstname, '') <> '' THEN ' ' ELSE '' END || + COALESCE(firstname, '') || + CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(name_company, '') || + CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(acronym, '') + ) + ) "); $this->addSql(" CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php new file mode 100644 index 000000000..f9475e932 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE chill_3party.third_party ADD firstname VARCHAR(255) DEFAULT \'""\' NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE chill_3party.third_party DROP firstname'); + } +} From a24cd693e3e4176a45b35dafe8b79bbcaef877bc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 10:23:47 +0100 Subject: [PATCH 05/26] firstname field added to twig form for child or contact types --- .../Entity/ThirdParty.php | 35 ++++++++----------- .../Form/ThirdPartyType.php | 4 +++ .../views/ThirdParty/_form.html.twig | 4 +++ .../_form_thirdparty_children.html.twig | 5 +++ .../Resources/views/ThirdParty/view.html.twig | 2 +- .../translations/messages.fr.yml | 1 + 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index db56dbd94..6e30c40dc 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -463,12 +463,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->email; } - /** - * Get id. - * - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -478,16 +473,16 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->kind; } - /** - * Get name. - * - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } + public function getFirstname(): string + { + return $this->firstname; + } + public function getNameCompany(): ?string { return $this->nameCompany; @@ -782,20 +777,20 @@ 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; return $this; } + public function setFirstname($firstname): self + { + $this->firstname = $firstname; + + return $this; + } + /** * @param string $nameCompany */ diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 480808dfe..28e87c584 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' => true, + ]) ->add('civility', PickCivilityType::class, [ 'label' => 'thirdparty.Civility', 'placeholder' => 'thirdparty.choose civility', diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig index 4827ba19c..fffa44a6a 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig @@ -3,6 +3,10 @@ {{ form_row(form.civility) }} {% endif %} +{% if form.firstname is defined %} +{{ form_row(form.firstname) }} +{% endif %} + {{ form_row(form.name) }} {% if form.nameCompany is defined %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig index eac5c2a98..cffbf0ad7 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form_thirdparty_children.html.twig @@ -7,6 +7,11 @@ {{ form_errors(form.civility) }} {{ form_label(form.civility) }}
+
+ {{ form_widget(form.firstname) }} + {{ form_errors(form.firstname) }} + {{ form_label(form.firstname) }} +
{{ form_widget(form.name) }} {{ form_errors(form.name) }} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig index c4f2bcfbd..3dac7a0dd 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig @@ -25,7 +25,7 @@
{{ 'Name'|trans }}
{% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %} - {{ thirdParty.name }} + {{ thirdParty.firstname ~ ' ' ~ thirdParty.name }}
{% if thirdParty.kind == 'company' %} diff --git a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml index 20b45a398..4607f5ba9 100644 --- a/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillThirdPartyBundle/translations/messages.fr.yml @@ -1,6 +1,7 @@ Third party: Tiers Third parties: Tiers third parties: tiers +firstname: Prénom name: Nom telephone: Téléphone adress: Adresse From f44f9d356b3d870e8bee57cf36d24c78a26a2cde Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 11:16:58 +0100 Subject: [PATCH 06/26] migration adjusted to have actual empty string instead of '' --- .../ChillThirdPartyBundle/migrations/Version20220311133150.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php index f9475e932..aec6669d8 100644 --- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php @@ -20,7 +20,7 @@ final class Version20220311133150 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE chill_3party.third_party ADD firstname VARCHAR(255) DEFAULT \'""\' NOT NULL'); + $this->addSql('ALTER TABLE chill_3party.third_party ADD firstname VARCHAR(255) DEFAULT \'\' NOT NULL'); } public function down(Schema $schema): void From 09e68727245af9b21fd2535f66e9bb8a8234d4a2 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 11:48:39 +0100 Subject: [PATCH 07/26] firstname added to onthefly for child or contact --- .../vuejs/_components/OnTheFly/ThirdParty.vue | 16 +++++++++++++--- .../Resources/public/vuejs/_js/i18n.js | 2 ++ .../Normalizer/ThirdPartyNormalizer.php | 1 + .../Templating/Entity/ThirdPartyRender.php | 4 +++- .../ChillThirdPartyBundle/chill.api.specs.yaml | 2 ++ 5 files changed, 21 insertions(+), 4 deletions(-) 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 8de41b989..9ed4481dd 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -65,7 +65,7 @@
-
+
+
+
+ + +
+
+ + +
+
-
+
@@ -307,7 +317,7 @@ dl { margin-bottom: 1rem; } -#child-info { +.child-info { display: flex; justify-content: space-between; div { diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js index 76f01e3f4..04cfc0cf4 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js @@ -1,6 +1,8 @@ const thirdpartyMessages = { fr: { thirdparty: { + firstname: "Prénom", + lastname: "Nom", name: "Dénomination", email: "Courriel", phonenumber: "Téléphone", diff --git a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php index 8e4775aad..87bfb6995 100644 --- a/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php +++ b/src/Bundle/ChillThirdPartyBundle/Serializer/Normalizer/ThirdPartyNormalizer.php @@ -43,6 +43,7 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf { return [ 'type' => 'thirdparty', + 'firstname' => $thirdParty->getFirstname(), 'name' => $thirdParty->getName(), 'text' => $this->thirdPartyRender->renderString($thirdParty, []), 'id' => $thirdParty->getId(), diff --git a/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php b/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php index 8cfa95f80..cec9dee7d 100644 --- a/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php +++ b/src/Bundle/ChillThirdPartyBundle/Templating/Entity/ThirdPartyRender.php @@ -77,7 +77,9 @@ class ThirdPartyRender extends AbstractChillEntityRender $acronym = ''; } - return $civility . $entity->getName() . $acronym; + $firstname = empty($entity->getFirstname()) ? '' : $entity->getFirstname(); + + return $civility . $firstname . ' ' . $entity->getName() . $acronym; } public function supports($entity, array $options): bool diff --git a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml index eb303a4f0..035185181 100644 --- a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml @@ -20,6 +20,8 @@ components: type: string enum: - "thirdparty" + firstname: + type: string name: type: string email: From 96e38a8a6de08da64a60a8306c8dc0055b0b53b2 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 11:49:01 +0100 Subject: [PATCH 08/26] eventlistener added to capitalize names correctly --- .../ChillThirdPartyExtension.php | 1 + .../EventListener/ThirdPartyEventListener.php | 31 +++++++++++++++++++ .../services/doctrineEventListener.yaml | 9 ++++++ 3 files changed, 41 insertions(+) create mode 100644 src/Bundle/ChillThirdPartyBundle/EventListener/ThirdPartyEventListener.php create mode 100644 src/Bundle/ChillThirdPartyBundle/config/services/doctrineEventListener.yaml 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/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/config/services/doctrineEventListener.yaml b/src/Bundle/ChillThirdPartyBundle/config/services/doctrineEventListener.yaml new file mode 100644 index 000000000..8c48e125e --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/config/services/doctrineEventListener.yaml @@ -0,0 +1,9 @@ +services: + Chill\ThirdPartyBundle\EventListener\ThirdPartyEventListener: + autoconfigure: true + tags: + - + name: 'doctrine.orm.entity_listener' + event: 'prePersist' + entity: 'Chill\ThirdPartyBundle\Entity\ThirdParty' + method: 'prePersistThirdParty' \ No newline at end of file From 4ea72f7d9d208ae6cbab1d1076be70bb0b2a5b38 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 11:49:58 +0100 Subject: [PATCH 09/26] csfixes --- .../Entity/ThirdParty.php | 42 +++++++++---------- .../migrations/Version20220311133150.php | 19 ++++++--- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 6e30c40dc..766c74a39 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -197,6 +197,15 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface */ private ?string $email = null; + /** + * @ORM\Column(name="firstname", type="string", length=255) + * @Assert\Length(min="2") + * @Assert\NotNull + * @Assert\NotBlank + * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) + */ + private ?string $firstname = ''; + /** * @var int * @ORM\Column(name="id", type="integer") @@ -222,15 +231,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface */ private ?string $name = ''; - /** - * @ORM\Column(name="firstname", type="string", length=255) - * @Assert\Length(min="2") - * @Assert\NotNull - * @Assert\NotBlank - * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) - */ - private ?string $firstname = ''; - /** * [fr] Raison sociale. * @@ -463,6 +463,11 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->email; } + public function getFirstname(): string + { + return $this->firstname; + } + public function getId(): ?int { return $this->id; @@ -478,11 +483,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this->name; } - public function getFirstname(): string - { - return $this->firstname; - } - public function getNameCompany(): ?string { return $this->nameCompany; @@ -770,6 +770,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; @@ -784,13 +791,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setFirstname($firstname): self - { - $this->firstname = $firstname; - - return $this; - } - /** * @param string $nameCompany */ diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php index aec6669d8..768cd9533 100644 --- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220311133150.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE chill_3party.third_party DROP firstname'); + } + public function getDescription(): string { return 'Adding firstname to thirdparty'; @@ -22,10 +35,4 @@ final class Version20220311133150 extends AbstractMigration // this up() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE chill_3party.third_party ADD firstname VARCHAR(255) DEFAULT \'\' NOT NULL'); } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE chill_3party.third_party DROP firstname'); - } } From 0546a43d631f51ed14da0d12ac51fabc6f421f71 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 14 Mar 2022 13:41:32 +0100 Subject: [PATCH 10/26] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 885068bc0..118e0c705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to * [thirdparty] Add parameter condition to display centers or not (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/500) * [phonenumber] Remove placeholder in phonenumber field (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/496) * [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) +* [thirdparty] add firstname field to thirdparty 'child' or 'contact' types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/508) ## Test releases From 6151d0ce54346bcf7cd80eec851969dfd2e95e40 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 16 Mar 2022 12:32:54 +0100 Subject: [PATCH 11/26] fix name suggestion badges underneath input fields --- .../vuejs/_components/OnTheFly/Person.vue | 40 +++++----- .../vuejs/_components/OnTheFly/ThirdParty.vue | 80 +++++++++++++------ 2 files changed, 77 insertions(+), 43 deletions(-) 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 @@
-
    -
  • {{ e }}
  • -
+
    +
  • {{ e }}
  • +
@@ -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/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 9ed4481dd..c61d98aea 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 }} +
  • +
+