From 58f1984c7770bac5d51ee7d4b17635dd5047ffc9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 25 Mar 2022 15:14:13 +0100 Subject: [PATCH 001/111] Add new fields to AddressReference for update procedure --- .../Entity/AddressReference.php | 55 +++++++++++++++++++ .../migrations/Version20220325134944.php | 43 +++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20220325134944.php diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php index a9d421fcb..fe132f883 100644 --- a/src/Bundle/ChillMainBundle/Entity/AddressReference.php +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Entity; use Chill\MainBundle\Doctrine\Model\Point; +use DateTimeImmutable; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; @@ -33,6 +34,18 @@ class AddressReference */ private string $addressCanonical = ''; + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $createdAt = null; + + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $deletedAt = null; + /** * @ORM\Id * @ORM\GeneratedValue @@ -89,6 +102,22 @@ class AddressReference */ private $streetNumber; + /** + * @ORM\Column(type="datetime_immutable", nullable=true) + * @groups({"read"}) + */ + private ?DateTimeImmutable $updatedAt = null; + + public function getCreatedAt(): ?DateTimeImmutable + { + return $this->createdAt; + } + + public function getDeletedAt(): ?DateTimeImmutable + { + return $this->deletedAt; + } + public function getId(): ?int { return $this->id; @@ -134,6 +163,25 @@ class AddressReference return $this->streetNumber; } + public function getUpdatedAt(): ?DateTimeImmutable + { + return $this->updatedAt; + } + + public function setCreatedAt(?DateTimeImmutable $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } + + public function setDeletedAt(?DateTimeImmutable $deletedAt): self + { + $this->deletedAt = $deletedAt; + + return $this; + } + public function setMunicipalityCode(?string $municipalityCode): self { $this->municipalityCode = $municipalityCode; @@ -189,4 +237,11 @@ class AddressReference return $this; } + + public function setUpdatedAt(?DateTimeImmutable $updatedAt): self + { + $this->updatedAt = $updatedAt; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php b/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php new file mode 100644 index 000000000..bc0382482 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20220325134944.php @@ -0,0 +1,43 @@ +addSql('ALTER TABLE chill_main_address_reference DROP createdAt'); + $this->addSql('ALTER TABLE chill_main_address_reference DROP deletedAt'); + $this->addSql('ALTER TABLE chill_main_address_reference DROP updatedAt'); + } + + public function getDescription(): string + { + return 'Add 3 fields on AddressReference'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_address_reference ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD deletedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.deletedAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_main_address_reference.updatedAt IS \'(DC2Type:datetime_immutable)\''); + } +} From c3731ae2db2a35d60fc0fd59e84ff279d42ab0f1 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 5 Apr 2022 10:21:14 +0200 Subject: [PATCH 002/111] address reference: add filtering by deletedAt --- .../Controller/AddressReferenceAPIController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php index 1a7d8956a..1ac7a87fe 100644 --- a/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php +++ b/src/Bundle/ChillMainBundle/Controller/AddressReferenceAPIController.php @@ -76,7 +76,8 @@ final class AddressReferenceAPIController extends ApiController protected function customizeQuery(string $action, Request $request, $qb): void { if ($request->query->has('postal_code')) { - $qb->where('e.postcode = :postal_code') + $qb->where($qb->expr()->isNull('e.deletedAt')) + ->andWhere('e.postcode = :postal_code') ->setParameter('postal_code', $request->query->get('postal_code')); } } From c1ec2933e589f74c32487bc1dbade2acd3e59169 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 14 Apr 2022 17:08:44 +0200 Subject: [PATCH 003/111] 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 004/111] 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 @@ +
+ + +
+