From 88362bd284a1c77e8ab00b1a1b0d9625e8d7f386 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 25 Aug 2021 17:46:51 +0200 Subject: [PATCH 001/112] start of updating personrenderbox to display age. only one scenario done --- .../Resources/public/vuejs/_js/i18n.js | 3 ++- .../_components/Entity/PersonRenderBox.vue | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js index 84db72236..9c28c9fdb 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js @@ -76,7 +76,8 @@ const messages = { birthday: { man: "Né le", woman: "Née le" - } , + }, + years_old: "ans", no_data: "Aucune information renseignée", type: { thirdparty: "Tiers", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 464e2190e..0a8a8da9f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -27,7 +27,7 @@ -

+

@@ -114,12 +114,14 @@ export default { return this.person.gender == 'woman' ? 'fa-venus' : this.person.gender == 'man' ? 'fa-mars' : 'fa-neuter'; }, birthdate: function(){ - var date = new Date(this.person.birthdate.datetime); + const date = new Date(this.person.birthdate.datetime); return dateToISO(date); }, deathdate: function(){ - var date = new Date(this.person.deathdate.datetime); + if(this.person.deathdate){ + const date = new Date(this.person.deathdate.datetime); return dateToISO(date); + } }, altNameLabel: function(){ for(let i = 0; i < this.person.altNames.length; i++){ @@ -131,6 +133,12 @@ export default { return this.person.altNames[i].key } }, + getAge: function(){ + if(this.person.birthdate && !this.person.deathdate){ + const birthday = new Date(this.person.birthdate.datetime) + const now = new Date() + return (now.getFullYear() - birthday.getFullYear()) + } } } @@ -153,6 +161,12 @@ div.flex-table { } } } + +.age{ + margin-left: 0.5em; + &:before { content: '('; } + &:after { content: ')'; } +} From 5194cad354ebb8873d66c362399a8e289f7d35cb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 26 Aug 2021 14:53:04 +0200 Subject: [PATCH 002/112] Adaptations for display of age and deathdate (different scenarios not all finished) --- .../Resources/public/vuejs/_js/i18n.js | 1 + .../_components/Entity/PersonRenderBox.vue | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js index 9c28c9fdb..593d76f7d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js @@ -77,6 +77,7 @@ const messages = { man: "Né le", woman: "Née le" }, + deathdate: "Date de décès", years_old: "ans", no_data: "Aucune information renseignée", type: { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 0a8a8da9f..f886a3d29 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -28,12 +28,16 @@

+ {{ person.deathdate }} -

@@ -100,7 +104,7 @@ export default { }, props: ['person', 'options'], computed: { - getGender: function() { + getGenderTranslation: function() { return this.person.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man'; }, isMultiline: function() { @@ -138,6 +142,17 @@ export default { const birthday = new Date(this.person.birthdate.datetime) const now = new Date() return (now.getFullYear() - birthday.getFullYear()) + } else if(this.person.birthdate && this.person.deathdate){ + const birthday = new Date(this.person.birthdate.datetime) + const deathdate = new Date(this.person.deathdate.datetime) + return (deathdate.getFullYear() - birthday.getFullYear()) + } else if(!this.person.birthdate && this.person.deathdate.datetime) { + // todo: change this + return "Age unknown" + } else { + // todo: change this + return "Age unknown" + } } } } From c5f40c53ea258e8dd982ed43f87816ddb2e71993 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 26 Aug 2021 16:42:33 +0200 Subject: [PATCH 003/112] further adaptations to display deathdate. deathdate added to what API returns --- .../PersonsAssociated/ParticipationItem.vue | 2 +- .../_components/Entity/PersonRenderBox.vue | 9 +- .../Normalizer/PersonNormalizer.php | 2 + .../ChillPersonBundle/chill.api.specs.yaml | 138 ++++++++---------- 4 files changed, 72 insertions(+), 79 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue index 04c6b73a9..704f66be3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated/ParticipationItem.vue @@ -6,7 +6,7 @@ addEntity: false, addLink: false, addAltNames: true, - addAge : false, + addAge : true, hLevel : 3, }" :person="participation.person"> diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index f886a3d29..82948a37a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -28,7 +28,6 @@

- {{ person.deathdate }}

@@ -118,13 +117,15 @@ export default { return this.person.gender == 'woman' ? 'fa-venus' : this.person.gender == 'man' ? 'fa-mars' : 'fa-neuter'; }, birthdate: function(){ + if(this.person.birthdate){ const date = new Date(this.person.birthdate.datetime); - return dateToISO(date); + return dateToISO(date) + } }, deathdate: function(){ if(this.person.deathdate){ const date = new Date(this.person.deathdate.datetime); - return dateToISO(date); + return date.toLocaleDateString("fr-FR"); } }, altNameLabel: function(){ diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php index cde495f52..3dabb43cb 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonNormalizer.php @@ -69,6 +69,7 @@ class PersonNormalizer implements 'firstName' => $person->getFirstName(), 'lastName' => $person->getLastName(), 'birthdate' => $this->normalizer->normalize($person->getBirthdate()), + 'deathdate' => $this->normalizer->normalize($person->getDeathdate()), 'center' => $this->normalizer->normalize($person->getCenter()), 'phonenumber' => $person->getPhonenumber(), 'mobilenumber' => $person->getMobilenumber(), @@ -125,6 +126,7 @@ class PersonNormalizer implements foreach ([ 'birthdate' => \DateTime::class, + 'deathdate' => \DateTime::class, 'center' => Center::class ] as $item => $class) { if (\array_key_exists($item, $data)) { diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml index 1b2c9cd85..020fa409f 100644 --- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml @@ -45,7 +45,7 @@ components: type: type: string enum: - - 'person' + - "person" firstName: type: string lastName: @@ -55,7 +55,9 @@ components: description: a canonical representation for the person name readOnly: true birthdate: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" + deathdate: + $ref: "#/components/schemas/Date" phonenumber: type: string mobilenumber: @@ -78,7 +80,7 @@ components: type: type: string enum: - - 'person' + - "person" required: - id - type @@ -96,7 +98,7 @@ components: type: type: string enum: - - 'thirdparty' + - "thirdparty" required: - id - type @@ -119,15 +121,15 @@ components: type: type: string enum: - - 'accompanying_period_resource' + - "accompanying_period_resource" readOnly: true id: type: integer readOnly: true resource: anyOf: - - $ref: '#/components/schemas/PersonById' - - $ref: '#/components/schemas/ThirdPartyById' + - $ref: "#/components/schemas/PersonById" + - $ref: "#/components/schemas/ThirdPartyById" ResourceById: type: object properties: @@ -136,7 +138,7 @@ components: type: type: string enum: - - 'accompanying_period_resource' + - "accompanying_period_resource" required: - id - type @@ -146,7 +148,7 @@ components: type: type: string enum: - - 'accompanying_period_comment' + - "accompanying_period_comment" readOnly: true id: type: integer @@ -161,7 +163,7 @@ components: type: type: string enum: - - 'accompanying_period_comment' + - "accompanying_period_comment" required: - id - type @@ -173,7 +175,7 @@ components: type: type: string enum: - - 'social_issue' + - "social_issue" parent_id: type: integer readOnly: true @@ -195,12 +197,12 @@ components: Household: type: object properties: - id: - type: integer - type: - type: string - enum: - - 'household' + id: + type: integer + type: + type: string + enum: + - "household" HouseholdPosition: type: object properties: @@ -209,7 +211,7 @@ components: type: type: string enum: - - 'household_position' + - "household_position" AccompanyingCourseWork: type: object properties: @@ -218,7 +220,7 @@ components: type: type: string enum: - - 'accompanying_period_work' + - "accompanying_period_work" note: type: string startDate: @@ -243,15 +245,15 @@ components: type: type: string enum: - - 'accompanying_period_work_goal' + - "accompanying_period_work_goal" note: type: string goal: - $ref: '#/components/schemas/SocialWorkGoalById' + $ref: "#/components/schemas/SocialWorkGoalById" results: type: array items: - $ref: '#/components/schemas/SocialWorkGoalById' + $ref: "#/components/schemas/SocialWorkGoalById" SocialWorkResultById: type: object @@ -261,7 +263,7 @@ components: type: type: string enum: - - 'social_work_result' + - "social_work_result" SocialWorkGoalById: type: object properties: @@ -270,7 +272,7 @@ components: type: type: string enum: - - 'social_work_goal' + - "social_work_goal" paths: /1.0/person/person/{id}.json: @@ -308,7 +310,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Person' + $ref: "#/components/schemas/Person" responses: 200: description: "OK" @@ -355,18 +357,17 @@ paths: 422: description: "Unprocessable entity (validation errors)" - /1.0/person/address/suggest/by-person/{id}.json: get: tags: - address summary: get a list of suggested address for a person description: > - The address are computed from various source. Currently: + The address are computed from various source. Currently: - - the address of course to which the person is participating + - the address of course to which the person is participating - The current person's address is always ignored. + The current person's address is always ignored. parameters: - name: id in: path @@ -390,11 +391,11 @@ paths: - address summary: get a list of suggested address for a household description: > - The address are computed from various source. Currently: + The address are computed from various source. Currently: - - the address of course to which the members is participating + - the address of course to which the members is participating - The current household address is always ignored. + The current household address is always ignored. parameters: - name: id in: path @@ -452,7 +453,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AccompanyingPeriod' + $ref: "#/components/schemas/AccompanyingPeriod" examples: Set the requestor as anonymous: value: @@ -488,7 +489,7 @@ paths: id: 0 personLocation: null addressLocation: - id: 7960 + id: 7960 responses: 401: description: "Unauthorized" @@ -520,8 +521,8 @@ paths: application/json: schema: oneOf: - - $ref: '#/components/schemas/PersonById' - - $ref: '#/components/schemas/ThirdPartyById' + - $ref: "#/components/schemas/PersonById" + - $ref: "#/components/schemas/ThirdPartyById" examples: add person with id 50: summary: "a person with id 50" @@ -585,7 +586,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PersonById' + $ref: "#/components/schemas/PersonById" responses: 401: description: "Unauthorized" @@ -614,7 +615,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PersonById' + $ref: "#/components/schemas/PersonById" responses: 401: description: "Unauthorized" @@ -645,7 +646,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Resource' + $ref: "#/components/schemas/Resource" examples: add person with id 50: summary: "a person with id 50" @@ -690,7 +691,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ResourceById' + $ref: "#/components/schemas/ResourceById" responses: 401: description: "Unauthorized" @@ -721,7 +722,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Comment' + $ref: "#/components/schemas/Comment" examples: a single comment: summary: "a simple comment" @@ -759,7 +760,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CommentById' + $ref: "#/components/schemas/CommentById" responses: 401: description: "Unauthorized" @@ -790,7 +791,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Scope' + $ref: "#/components/schemas/Scope" examples: add a scope: value: @@ -824,7 +825,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ScopeById' + $ref: "#/components/schemas/ScopeById" responses: 401: description: "Unauthorized" @@ -855,7 +856,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SocialIssue' + $ref: "#/components/schemas/SocialIssue" examples: add a social issue: value: @@ -889,7 +890,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SocialIssue' + $ref: "#/components/schemas/SocialIssue" responses: 401: description: "Unauthorized" @@ -926,11 +927,11 @@ paths: type: type: string enum: - - 'accompanying_period_work' + - "accompanying_period_work" startDate: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" endDate: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" examples: create a work: value: @@ -992,7 +993,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/AccompanyingCourseWork' + $ref: "#/components/schemas/AccompanyingCourseWork" responses: 401: description: "Unauthorized" @@ -1029,8 +1030,6 @@ paths: 400: description: "transition cannot be applyed" - - /1.0/person/accompanying-period/origin.json: get: tags: @@ -1064,8 +1063,6 @@ paths: 404: description: "Not found" - - /1.0/person/household.json: get: tags: @@ -1095,7 +1092,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Household' + $ref: "#/components/schemas/Household" 404: description: "not found" 401: @@ -1107,9 +1104,9 @@ paths: - household summary: Return households associated with the given person through accompanying periods description: | - Return households associated with the given person throught accompanying periods participation. + Return households associated with the given person throught accompanying periods participation. - The current household of the given person is excluded. + The current household of the given person is excluded. parameters: - name: person_id in: path @@ -1125,7 +1122,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Household' + $ref: "#/components/schemas/Household" 404: description: "not found" 401: @@ -1149,23 +1146,22 @@ paths: type: object properties: person: - $ref: '#/components/schemas/PersonById' + $ref: "#/components/schemas/PersonById" start_date: - $ref: '#/components/schemas/Date' + $ref: "#/components/schemas/Date" position: - $ref: '#/components/schemas/HouseholdPosition' + $ref: "#/components/schemas/HouseholdPosition" holder: type: boolean comment: type: string destination: - $ref: '#/components/schemas/Household' + $ref: "#/components/schemas/Household" examples: Moving person to a new household: value: concerned: - - - person: + - person: id: 0 type: person position: @@ -1180,8 +1176,7 @@ paths: Moving person to a new household and set an address to this household: value: concerned: - - - person: + - person: id: 0 type: person position: @@ -1198,8 +1193,7 @@ paths: Moving person to an existing household: value: concerned: - - - person: + - person: id: 0 type: person position: @@ -1215,8 +1209,7 @@ paths: Removing a person from any household: value: concerned: - - - person: + - person: id: 0 type: person start_date: @@ -1270,8 +1263,6 @@ paths: 400: description: "transition cannot be applyed" - - /1.0/person/social/social-action.json: get: tags: @@ -1349,7 +1340,6 @@ paths: 404: description: not found - /1.0/person/social-work/social-issue.json: get: tags: @@ -1379,7 +1369,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/SocialIssue' + $ref: "#/components/schemas/SocialIssue" 404: description: "not found" 401: From 8182e35c9c424475bb1e0218764d48677d3e51a1 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 27 Aug 2021 15:13:21 +0200 Subject: [PATCH 004/112] renderbox options changed to not display age for thirdparties, but yes in person modal --- .../public/vuejs/AccompanyingCourse/components/Requestor.vue | 2 +- .../AccompanyingCourse/components/Resources/ResourceItem.vue | 2 +- .../Resources/public/vuejs/_components/OnTheFly/Person.vue | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index 1cb96bc69..6097d6d46 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -16,7 +16,7 @@ addLink: false, addId: false, addEntity: true, - addInfo: true, + addInfo: false, hLevel: 3, isMultiline: true }" 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 d37a4b84f..a1e2b3b10 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 @@ -17,7 +17,7 @@ - From 903d57ea9dfc1b349dda7cdd9b62fb48b7a43bee Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 1 Sep 2021 17:36:17 +0200 Subject: [PATCH 009/112] person_renderbox fix if there is no birthdate --- .../public/vuejs/_components/Entity/PersonRenderBox.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 82948a37a..38039501d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -117,15 +117,19 @@ export default { return this.person.gender == 'woman' ? 'fa-venus' : this.person.gender == 'man' ? 'fa-mars' : 'fa-neuter'; }, birthdate: function(){ - if(this.person.birthdate){ + if(this.person.birthdate !== null){ const date = new Date(this.person.birthdate.datetime); return dateToISO(date) + } else { + return ""; } }, deathdate: function(){ - if(this.person.deathdate){ + if(this.person.deathdate !== null){ const date = new Date(this.person.deathdate.datetime); return date.toLocaleDateString("fr-FR"); + } else { + return ""; } }, altNameLabel: function(){ From a4f446c6b92e2040b191294d97b259812ab16bd8 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 15 Sep 2021 11:42:02 +0200 Subject: [PATCH 010/112] fix flashbag double col-8 --- src/Bundle/ChillMainBundle/Resources/views/layout.html.twig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index b11a4101f..dc500642c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -59,19 +59,19 @@
{% for flashMessage in app.session.flashbag.get('success') %} -
+
{{ flashMessage|raw }}
{% endfor %} {% for flashMessage in app.session.flashbag.get('error') %} -
+
{{ flashMessage|raw }}
{% endfor %} {% for flashMessage in app.session.flashbag.get('notice') %} -
+
{{ flashMessage|raw }}
{% endfor %} From 910016f72279db2cfa2a3a816d5739fe57055fdb Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 15 Sep 2021 11:50:03 +0200 Subject: [PATCH 011/112] tp: prepare address to be managed by vue (adapt formType) + add aliases methods isChild and isParent --- .../Entity/ThirdParty.php | 21 +++++++++- .../Form/ThirdPartyType.php | 38 ++++++++++++++----- .../config/services/form.yaml | 1 + 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 75da7ad78..0b0b3e56b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -152,6 +152,7 @@ class ThirdParty private $address; /** + * Soft-delete flag * @var boolean * @ORM\Column(name="active", type="boolean", options={"defaut": true}) */ @@ -498,11 +499,28 @@ class ThirdParty return $this; } + /** + * Mechanism to differentiate children and parents + */ public function isLeaf(): bool { return $this->children->count() !== 0; } + /** + * isLeaf aliases + */ + public function isChild():bool + { + return $this->isLeaf(); + } + + public function isParent():bool + { + return !$this->isLeaf(); + } + + /** * @return Collection */ @@ -527,7 +545,8 @@ class ThirdParty */ public function removeChild(ThirdParty $child): self { - $this->categories->removeElement($child); + $this->children->removeElement($child); + $this->active = false; return $this; } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 9db5013c3..30323794e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -2,6 +2,7 @@ namespace Chill\ThirdPartyBundle\Form; +use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Form\Type\ChillTextareaType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory; @@ -9,7 +10,9 @@ use Chill\ThirdPartyBundle\Entity\ThirdPartyCivility; use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; +use Doctrine\Persistence\ObjectManager; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; @@ -21,8 +24,7 @@ use Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\EmailType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Chill\MainBundle\Form\Type\AddressType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; class ThirdPartyType extends AbstractType @@ -35,16 +37,20 @@ class ThirdPartyType extends AbstractType protected TranslatableStringHelper $translatableStringHelper; + protected ObjectManager $om; + public function __construct( AuthorizationHelper $authorizationHelper, TokenStorageInterface $tokenStorage, ThirdPartyTypeManager $typesManager, - TranslatableStringHelper $translatableStringHelper + TranslatableStringHelper $translatableStringHelper, + ObjectManager $om ) { $this->authorizationHelper = $authorizationHelper; $this->tokenStorage = $tokenStorage; $this->typesManager = $typesManager; $this->translatableStringHelper = $translatableStringHelper; + $this->om = $om; } /** @@ -88,11 +94,6 @@ class ThirdPartyType extends AbstractType ->add('email', EmailType::class, [ 'required' => false ]) - ->add('address', AddressType::class, [ - 'has_valid_from' => false, - 'null_if_empty' => true, - 'required' => false - ]) ->add('active', ChoiceType::class, [ 'label' => 'thirdparty.Status', 'choices' => [ @@ -112,9 +113,28 @@ class ThirdPartyType extends AbstractType 'attr' => ['class' => 'select2'] ]) ; + $builder->add('address', HiddenType::class); + $builder->get('address') + ->addModelTransformer(new CallbackTransformer( + function (?Address $address): string { + if (null === $address) { + return ''; + } + return $address->getId(); + }, + function (string $addressId): ?Address { + if ('' === $addressId) { + return null; + } + return $this->om + ->getRepository(Address::class) + ->findOneBy(['id' => (int) $addressId]); + } + )) + ; // Contact Person ThirdParty (child) - if ($options['data']->isLeaf()) { + if ($options['data']->isChild()) { $builder ->add('civility', EntityType::class, [ 'label' => 'thirdparty.Civility', diff --git a/src/Bundle/ChillThirdPartyBundle/config/services/form.yaml b/src/Bundle/ChillThirdPartyBundle/config/services/form.yaml index de62b197c..8ff604769 100644 --- a/src/Bundle/ChillThirdPartyBundle/config/services/form.yaml +++ b/src/Bundle/ChillThirdPartyBundle/config/services/form.yaml @@ -5,6 +5,7 @@ services: $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' $typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager' $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' + $om: '@doctrine.orm.entity_manager' tags: - { name: form.type } From 4046a7ca9bbfef514a12d1b560150277e0aa90ce Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 15 Sep 2021 12:14:03 +0200 Subject: [PATCH 012/112] before resume dashboards: disable accompanyingCourse resume persons, requestor, and resources --- .../views/AccompanyingCourse/index.html.twig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index f210c4a49..be66abe73 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -34,6 +34,9 @@
{% endif %} +
WIP .. AccompanyingCourse Resume dashboard
+ + {#

{{ 'Resume Accompanying Course'|trans }}

@@ -50,11 +53,13 @@ {% endif %} {% endfor %}
+ #} {% if 'DRAFT' != accompanyingCourse.step %} {% if withoutHousehold|length > 0 %} {% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %} {% endif %} {% endif %} + {#
@@ -75,12 +80,11 @@
{% endif %} - + #} {% if accompanyingCourse.locationStatus == 'address' or accompanyingCourse.locationStatus == 'none' %} {% include '@ChillPerson/AccompanyingCourse/_warning_address.html.twig' with {} %} {% endif %} - - + {#
@@ -128,6 +132,8 @@
{% endif %} + #} +