From c1ec2933e589f74c32487bc1dbade2acd3e59169 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 14 Apr 2022 17:08:44 +0200 Subject: [PATCH 01/19] person: create a new person: add a civility field --- src/Bundle/ChillPersonBundle/Form/CreationPersonType.php | 6 ++++++ .../Resources/views/Person/create.html.twig | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php index 2aed9df97..22fd0a12d 100644 --- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Form\Event\CustomizeFormEvent; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillPhoneNumberType; use Chill\MainBundle\Form\Type\PickCenterType; +use Chill\MainBundle\Form\Type\PickCivilityType; use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Form\Type\GenderType; @@ -55,6 +56,11 @@ final class CreationPersonType extends AbstractType $builder ->add('firstName') ->add('lastName') + ->add('civility', PickCivilityType::class, [ + 'required' => false, + 'label' => 'Civility', + 'placeholder' => 'choose civility', + ]) ->add('gender', GenderType::class, [ 'required' => true, 'placeholder' => null, ]) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig index 3a9083310..a5c99379f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/create.html.twig @@ -93,6 +93,8 @@ {{ form_row(form.gender, { 'label' : 'Gender'|trans }) }} + {{ form_row(form.civility, { 'label' : 'Civility'|trans }) }} + {{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }} {{ form_row(form.phonenumber, { 'label' : 'Phonenumber'|trans }) }} From 7a2151f23a7e550d763fbb32cc5f7fd03a6ddb73 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 14 Apr 2022 18:04:36 +0200 Subject: [PATCH 02/19] AddPerson: add civility when creating a person --- .../vuejs/OnTheFly/components/OnTheFly.vue | 3 +- .../Resources/public/vuejs/_api/OnTheFly.js | 8 ++++- .../public/vuejs/_components/AddPersons.vue | 2 +- .../vuejs/_components/OnTheFly/Person.vue | 30 +++++++++++++++++-- .../Resources/public/vuejs/_js/i18n.js | 4 +++ 5 files changed, 41 insertions(+), 6 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 669c225dd..5949a1e56 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -210,7 +210,6 @@ export default { let type = this.type, data = {} ; - switch (type) { case 'person': data = this.$refs.castPerson.$data.person; @@ -238,7 +237,7 @@ export default { if (typeof data.civility !== 'undefined' && null !== data.civility) { data.civility = data.civility !== null ? {type: 'chill_main_civility', id: data.civility.id} : null; } - if (typeof data.civility !== 'undefined' && null !== data.profession) { + if (typeof data.profession !== 'undefined' && null !== data.profession) { data.profession = data.profession !== null ? {type: 'third_party_profession', id: data.profession.id} : null; } // console.log('onthefly data', data); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js index 20ed1c8da..338094122 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_api/OnTheFly.js @@ -14,8 +14,13 @@ const getPersonAltNames = () => fetch('/api/1.0/person/config/alt_names.json').then(response => { if (response.ok) { return response.json(); } throw Error('Error with request resource response'); - });; + }); +const getCivilities = () => + fetch('/api/1.0/main/civility.json').then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); /* * POST a new person @@ -56,6 +61,7 @@ const patchPerson = (id, body) => { export { getPerson, getPersonAltNames, + getCivilities, postPerson, patchPerson }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index 90505a1e2..47cae34b1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -277,7 +277,7 @@ export default { } }, saveFormOnTheFly({ type, data }) { - // console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); + console.log('saveFormOnTheFly from addPersons, type', type, ', data', data); if (type === 'person') { makeFetch('POST', '/api/1.0/person/person.json', data) .then(response => { 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 e6fa85902..940b4de41 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -87,6 +87,20 @@ +
+ + +
+