From 1c3c2be176ddc14df8222613dee76e49086e5c60 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Dec 2021 14:10:23 +0100 Subject: [PATCH 01/38] actions list: display badges as clickable onthefly modal --- .../listByAccompanyingCourse.html.twig | 9 +++++--- .../AccompanyingCourseWork/index.html.twig | 22 ++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index 07aed8686..215b7bb55 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -92,8 +92,11 @@ %}
- - {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': accompanyingCourse, 'with_display': 'row', 'entity': calendar } %} + {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { + 'context': accompanyingCourse, + 'with_display': 'row', + 'entity': calendar + } %}
{% if calendar.comment.comment is not empty %} @@ -123,4 +126,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig index 844b2d611..eb885d50a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig @@ -65,11 +65,12 @@
{% for p in w.persons %} - - {{ p|chill_entity_render_box({ - 'render': 'raw', - 'addAltNames': false - }) }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: p.id }, + buttonText: p|chill_entity_render_string + } %} {% endfor %}
@@ -82,11 +83,12 @@

{{ 'Thirdparty handling'|trans }}

- - {{ w.handlingThierParty|chill_entity_render_box({ - 'render': 'raw', - 'addAltNames': false - }) }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'thirdparty', id: w.handlingThierParty.id }, + buttonText: w.handlingThierParty|chill_entity_render_string + } %}
From 94ec165c4c84f534180368bc0e9eb36588e53217 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Dec 2021 14:23:33 +0100 Subject: [PATCH 02/38] accompanyingCourse list: display badges as clickable onthefly modal --- CHANGELOG.md | 7 +++-- .../views/AccompanyingPeriod/_list.html.twig | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef98f3e1..20a25edc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,10 +24,13 @@ and this project adheres to * [visgraph] improve and fix bugs on vis-network relationship graph * [bugfix] posting of birth- and deathdate through api fixed. * [suggestions] improve suggestions lists -* [badge-entity] design coherency between badge-person and 3 kinds of badge-thirdparty +* [badge-entity] design coherency between pills badge-person and 3 kinds of badge-thirdparty * [AddPersons] suggestions row are clickable, not only checkbox * [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl -* [activity][calendar] concerned groups items are clickable with on-the-fly modal, create specific badge for TMS column +* [badges] create specific badge for TMS, and make person/thirdparty badges clickable with on-the-fly modal in : + * concerned groups items (activity, calendar) + * accompanyingCourseWork lists + * accompanyingCourse lists ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig index af8657e28..ebfbed604 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig @@ -66,10 +66,22 @@

{{ 'Requestor'|trans({'gender': null }) }}

{% if accompanying_period.requestorPerson is not null %} - {{ accompanying_period.requestorPerson|chill_entity_render_string }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: accompanying_period.requestorPerson.id }, + buttonText: accompanying_period.requestorPerson|chill_entity_render_string + } %} + {% endif %} {% if accompanying_period.requestorThirdParty is not null %} - {{ accompanying_period.requestorThirdParty|chill_entity_render_string }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'thirdparty', id: accompanying_period.requestorThirdParty.id }, + buttonText: accompanying_period.requestorThirdParty|chill_entity_render_string + } %} + {% endif %}
@@ -80,13 +92,12 @@

{{ 'Participants'|trans }}

{% for p in accompanying_period.getCurrentParticipations %} - - - {{ p.person|chill_entity_render_string }} - - {# or in renderbox mode - {{ p.person|chill_entity_render_box({'render': 'label', 'addAltNames': false, 'addLink': true, 'hLevel': 5 }) }} - #} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: p.person.id }, + buttonText: p.person|chill_entity_render_string + } %} {% endfor %}
From 3592434623b0796576d9814bafa8a4c65f5932b9 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Dec 2021 15:37:12 +0100 Subject: [PATCH 03/38] onthefly create thirdparty: use badge-entity for radio buttons label --- .../vuejs/_components/OnTheFly/ThirdParty.vue | 30 +++++++------------ .../views/ThirdParty/update.html.twig | 2 +- 2 files changed, 12 insertions(+), 20 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 2d540530d..dc9025886 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -26,17 +26,19 @@
@@ -97,26 +99,16 @@ import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue'; import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress'; import { getThirdparty } from '../../_api/OnTheFly'; - -const i18n = { - messages: { - fr: { - tparty: { - contact: "Personne physique", - company: "Personne morale" - } - } - } -}; +import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue'; export default { name: "OnTheFlyThirdParty", props: ['id', 'type', 'action'], components: { ThirdPartyRenderBox, - AddAddress + AddAddress, + BadgeEntity }, - i18n, data() { return { //context: {}, <-- diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig index 75e165270..2d9c39002 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig @@ -12,7 +12,7 @@ {% block crud_content_header %}

{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }} - {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }} From 16b3be322a7286ebf23aef06d48bbb3bb0600f9e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Dec 2021 14:10:23 +0100 Subject: [PATCH 04/38] actions list: display badges as clickable onthefly modal --- .../listByAccompanyingCourse.html.twig | 9 +++++--- .../AccompanyingCourseWork/index.html.twig | 22 ++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index 07aed8686..215b7bb55 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -92,8 +92,11 @@ %}
- - {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': accompanyingCourse, 'with_display': 'row', 'entity': calendar } %} + {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { + 'context': accompanyingCourse, + 'with_display': 'row', + 'entity': calendar + } %}
{% if calendar.comment.comment is not empty %} @@ -123,4 +126,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig index 844b2d611..eb885d50a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig @@ -65,11 +65,12 @@
{% for p in w.persons %} - - {{ p|chill_entity_render_box({ - 'render': 'raw', - 'addAltNames': false - }) }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: p.id }, + buttonText: p|chill_entity_render_string + } %} {% endfor %}
@@ -82,11 +83,12 @@

{{ 'Thirdparty handling'|trans }}

- - {{ w.handlingThierParty|chill_entity_render_box({ - 'render': 'raw', - 'addAltNames': false - }) }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'thirdparty', id: w.handlingThierParty.id }, + buttonText: w.handlingThierParty|chill_entity_render_string + } %}
From d7db8400d23af9b0fa6116425ee4b492bbbeec1c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Dec 2021 14:23:33 +0100 Subject: [PATCH 05/38] accompanyingCourse list: display badges as clickable onthefly modal --- CHANGELOG.md | 7 +++-- .../views/AccompanyingPeriod/_list.html.twig | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7cb2cbc8..e98d70eb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,10 +46,13 @@ and this project adheres to * [visgraph] improve and fix bugs on vis-network relationship graph * [bugfix] posting of birth- and deathdate through api fixed. * [suggestions] improve suggestions lists -* [badge-entity] design coherency between badge-person and 3 kinds of badge-thirdparty +* [badge-entity] design coherency between pills badge-person and 3 kinds of badge-thirdparty * [AddPersons] suggestions row are clickable, not only checkbox * [activity] improve show/new/edit templates, fix SEE and SEE_DETAILS acl -* [activity][calendar] concerned groups items are clickable with on-the-fly modal, create specific badge for TMS column +* [badges] create specific badge for TMS, and make person/thirdparty badges clickable with on-the-fly modal in : + * concerned groups items (activity, calendar) + * accompanyingCourseWork lists + * accompanyingCourse lists ### Test release 2021-11-19 - bis diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig index af8657e28..ebfbed604 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig @@ -66,10 +66,22 @@

{{ 'Requestor'|trans({'gender': null }) }}

{% if accompanying_period.requestorPerson is not null %} - {{ accompanying_period.requestorPerson|chill_entity_render_string }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: accompanying_period.requestorPerson.id }, + buttonText: accompanying_period.requestorPerson|chill_entity_render_string + } %} + {% endif %} {% if accompanying_period.requestorThirdParty is not null %} - {{ accompanying_period.requestorThirdParty|chill_entity_render_string }} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'thirdparty', id: accompanying_period.requestorThirdParty.id }, + buttonText: accompanying_period.requestorThirdParty|chill_entity_render_string + } %} + {% endif %}
@@ -80,13 +92,12 @@

{{ 'Participants'|trans }}

{% for p in accompanying_period.getCurrentParticipations %} - - - {{ p.person|chill_entity_render_string }} - - {# or in renderbox mode - {{ p.person|chill_entity_render_box({'render': 'label', 'addAltNames': false, 'addLink': true, 'hLevel': 5 }) }} - #} + + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: p.person.id }, + buttonText: p.person|chill_entity_render_string + } %} {% endfor %}
From 6c28ff00abf2ec5b7ea5e065a6b557e40c387fb0 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Dec 2021 15:37:12 +0100 Subject: [PATCH 06/38] onthefly create thirdparty: use badge-entity for radio buttons label --- .../vuejs/_components/OnTheFly/ThirdParty.vue | 30 +++++++------------ .../views/ThirdParty/update.html.twig | 2 +- 2 files changed, 12 insertions(+), 20 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 2d540530d..dc9025886 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -26,17 +26,19 @@
@@ -97,26 +99,16 @@ import ThirdPartyRenderBox from '../Entity/ThirdPartyRenderBox.vue'; import AddAddress from 'ChillMainAssets/vuejs/Address/components/AddAddress'; import { getThirdparty } from '../../_api/OnTheFly'; - -const i18n = { - messages: { - fr: { - tparty: { - contact: "Personne physique", - company: "Personne morale" - } - } - } -}; +import BadgeEntity from 'ChillMainAssets/vuejs/_components/BadgeEntity.vue'; export default { name: "OnTheFlyThirdParty", props: ['id', 'type', 'action'], components: { ThirdPartyRenderBox, - AddAddress + AddAddress, + BadgeEntity }, - i18n, data() { return { //context: {}, <-- diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig index 75e165270..2d9c39002 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig @@ -12,7 +12,7 @@ {% block crud_content_header %}

{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }} - {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }} From 1e99ca2ca5ca94de53e6431e1f3be9fdcef115fe Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 13 Dec 2021 09:41:27 +0100 Subject: [PATCH 07/38] fix: add availableForUsers condition from locationType in the location API endpoint --- .../ChillMainBundle/Controller/LocationApiController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php index 525475e3c..aa5f46f1a 100644 --- a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php @@ -21,11 +21,14 @@ class LocationApiController extends ApiController { public function customizeQuery(string $action, Request $request, $query): void { - $query->andWhere( - $query->expr()->andX( + $query + ->leftJoin('e.locationType', 'lt') + ->andWhere( + $query->expr()->andX( $query->expr()->eq('e.availableForUsers', "'TRUE'"), + $query->expr()->eq('lt.availableForUsers', "'TRUE'"), $query->expr()->eq('e.active', "'TRUE'"), ) - ); + ); } } From 7129b3149b384bd68a47a195bd9a79fa09af47a6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 09:45:05 +0100 Subject: [PATCH 08/38] undo partial wip resolution --- src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 9697873e9..069dba9d8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -35,7 +35,6 @@ use function array_values; use function in_array; use function is_string; use function spl_object_hash; -use Symfony\Component\Serializer\Annotation\SerializedName; /** * ThirdParty is a party recorded in the database. @@ -222,7 +221,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @var array|null * @ORM\Column(name="types", type="json", nullable=true) - * @serializedName("3partyTypes") */ private $types; From 7f2e3ee8e2d2ebb9be52a687474cad2175a79ad5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 09:45:46 +0100 Subject: [PATCH 09/38] fix filiation error with gender undefined (#331) --- .../ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js | 1 + .../Resources/public/vuejs/VisGraph/vis-network.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js index 8047aea11..f0eb331a6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/i18n.js @@ -9,6 +9,7 @@ const visMessages = { both: 'neutre, non binaire', woman: 'féminin', man: 'masculin', + undefined: "genre non précisé", years: 'ans', click_to_expand: 'cliquez pour étendre', add_relationship_link: "Créer un lien de filiation", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js index 3e00db883..675ce63e9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/vis-network.js @@ -153,7 +153,7 @@ const getGender = (gender) => { case 'man': return visMessages.fr.visgraph.man default: - throw 'gender undefined' + return visMessages.fr.visgraph.undefined } } From 82c027fe2a019d99aad6979cfe2aaa652fcd5bd2 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 13 Dec 2021 11:04:10 +0100 Subject: [PATCH 10/38] add the current location of the user as API point + add it in the activity location list --- .../Resources/public/vuejs/Activity/api.js | 11 ++- .../vuejs/Activity/components/Location.vue | 78 ++++++++++--------- .../Controller/UserApiController.php | 21 +++++ .../Controller/UserApiControllerTest.php | 8 ++ .../ChillMainBundle/chill.api.specs.yaml | 8 ++ 5 files changed, 90 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js index 8d4bcac3b..edc0a616c 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/api.js @@ -17,6 +17,14 @@ const getLocations = () => fetchResults('/api/1.0/main/location.json'); const getLocationTypes = () => fetchResults('/api/1.0/main/location-type.json'); +const getUserCurrentLocation = + () => fetch('/api/1.0/main/user-current-location.json') + .then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); + + /* * Load Location Type by defaultFor * @param {string} entity - can be "person" or "thirdparty" @@ -48,5 +56,6 @@ export { getLocations, getLocationTypes, getLocationTypeByDefaultFor, - postLocation + postLocation, + getUserCurrentLocation }; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue index 9a4b78334..c9231006b 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue @@ -32,7 +32,7 @@ import { mapState, mapGetters } from "vuex"; import VueMultiselect from "vue-multiselect"; import NewLocation from "./Location/NewLocation.vue"; -import { getLocations, getLocationTypeByDefaultFor } from "../api.js"; +import { getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation } from "../api.js"; export default { name: "Location", @@ -60,46 +60,54 @@ export default { mounted() { getLocations().then( (results) => { - getLocationTypeByDefaultFor('person').then( - (personLocationType) => { - if (personLocationType) { - const personLocation = this.makeAccompanyingPeriodLocation(personLocationType); - const concernedPersonsLocation = - this.makeConcernedPersonsLocation(personLocationType); - getLocationTypeByDefaultFor('thirdparty').then( - thirdpartyLocationType => { - const concernedThirdPartiesLocation = - this.makeConcernedThirdPartiesLocation(thirdpartyLocationType); + getUserCurrentLocation().then( + userCurrentLocation => { + getLocationTypeByDefaultFor('person').then( + (personLocationType) => { + if (personLocationType) { + const personLocation = this.makeAccompanyingPeriodLocation(personLocationType); + const concernedPersonsLocation = + this.makeConcernedPersonsLocation(personLocationType); + getLocationTypeByDefaultFor('thirdparty').then( + thirdpartyLocationType => { + const concernedThirdPartiesLocation = + this.makeConcernedThirdPartiesLocation(thirdpartyLocationType); + this.locations = [ + { + locationGroup: 'Ma localisation', + locations: [userCurrentLocation] + }, + { + locationGroup: 'Localisation du parcours', + locations: [personLocation] + }, + { + locationGroup: 'Parties concernées', + locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation] + }, + { + locationGroup: 'Autres localisations', + locations: results + } + ]; + } + ) + } else { this.locations = [ { - locationGroup: 'Localisation du parcours', - locations: [personLocation] - }, - { - locationGroup: 'Parties concernées', - locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation] - }, - { - locationGroup: 'Autres localisations', - locations: results + locationGroup: 'Localisations', + locations: response.results } ]; } - ) - } else { - this.locations = [ - { - locationGroup: 'Localisations', - locations: response.results + if (window.default_location_id) { + let location = this.locations.filter( + (l) => l.id === window.default_location_id + ); + this.$store.dispatch("updateLocation", location); } - ]; - } - if (window.default_location_id) { - let location = this.locations.filter( - (l) => l.id === window.default_location_id - ); - this.$store.dispatch("updateLocation", location); - } + } + ) } ) }) diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index 75e566048..4b8a45c47 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -37,4 +37,25 @@ class UserApiController extends ApiController ['groups' => ['read']] ); } + + /** + * @Route( + * "/api/1.0/main/user-current-location.{_format}", + * name="chill_main_user_current_location", + * requirements={ + * "_format": "json" + * } + * ) + * + * @param mixed $_format + */ + public function currentLocation($_format): JsonResponse + { + return $this->json( + $this->getUser()->getCurrentLocation(), + JsonResponse::HTTP_OK, + [], + ['groups' => ['read']] + ); + } } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php index 813e9bc40..5d773972d 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -61,6 +61,14 @@ final class UserApiControllerTest extends WebTestCase $client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json'); + $this->assertResponseIsSuccessful(); + } + public function testUserCurrentLocation() + { + $client = $this->getClientAuthenticated(); + + $client->request(Request::METHOD_GET, '/api/1.0/main/user-current-location.json'); + $this->assertResponseIsSuccessful(); } } diff --git a/src/Bundle/ChillMainBundle/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml index fba3cfc19..db4430e48 100644 --- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml @@ -546,6 +546,14 @@ paths: responses: 200: description: "ok" + /1.0/main/user-current-location.json: + get: + tags: + - user + summary: Return the current location of the currently authenticated user + responses: + 200: + description: "ok" /1.0/main/user/{id}.json: get: tags: From 8493a64794ac86e00dc4c72aaeb685d618d05f83 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 13 Dec 2021 11:05:46 +0100 Subject: [PATCH 11/38] upd CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28144720b..a1f4e134a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to ## Unreleased +* [main] add availableForUsers condition from locationType in the location API endpoint (champs-libres/departement-de-la-vendee/accent-suivi-developpement#248) +* [main] add the current location of the user as API point + add it in the activity location list (champs-libres/departement-de-la-vendee/accent-suivi-developpement#247) + * [main] change address format in case the country is France, in Address render box and address normalizer * [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76) * [activity] fix visibility for location From 4b432c64b0ab7498a49eafd86406f50bedf58b6a Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 13 Dec 2021 11:07:30 +0100 Subject: [PATCH 12/38] php cs fixer --- .../Controller/UserApiController.php | 42 +++++++++---------- .../Controller/UserApiControllerTest.php | 17 ++++---- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index 4b8a45c47..d1fd4d5bb 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -17,27 +17,6 @@ use Symfony\Component\Routing\Annotation\Route; class UserApiController extends ApiController { - /** - * @Route( - * "/api/1.0/main/whoami.{_format}", - * name="chill_main_user_whoami", - * requirements={ - * "_format": "json" - * } - * ) - * - * @param mixed $_format - */ - public function whoami($_format): JsonResponse - { - return $this->json( - $this->getUser(), - JsonResponse::HTTP_OK, - [], - ['groups' => ['read']] - ); - } - /** * @Route( * "/api/1.0/main/user-current-location.{_format}", @@ -58,4 +37,25 @@ class UserApiController extends ApiController ['groups' => ['read']] ); } + + /** + * @Route( + * "/api/1.0/main/whoami.{_format}", + * name="chill_main_user_whoami", + * requirements={ + * "_format": "json" + * } + * ) + * + * @param mixed $_format + */ + public function whoami($_format): JsonResponse + { + return $this->json( + $this->getUser(), + JsonResponse::HTTP_OK, + [], + ['groups' => ['read']] + ); + } } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php index 5d773972d..d96f9647a 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -55,14 +55,6 @@ final class UserApiControllerTest extends WebTestCase return $data['results'][0]; } - public function testWhoami() - { - $client = $this->getClientAuthenticated(); - - $client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json'); - - $this->assertResponseIsSuccessful(); - } public function testUserCurrentLocation() { $client = $this->getClientAuthenticated(); @@ -71,4 +63,13 @@ final class UserApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); } + + public function testWhoami() + { + $client = $this->getClientAuthenticated(); + + $client->request(Request::METHOD_GET, '/api/1.0/main/whoami.json'); + + $this->assertResponseIsSuccessful(); + } } From b3ee745479aa19a4add98401350fb99b29d2ece6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 12:44:47 +0100 Subject: [PATCH 13/38] fix vue translation --- .../Resources/public/vuejs/AccompanyingCourse/js/i18n.js | 4 ---- .../public/vuejs/AccompanyingCourseWorkCreate/App.vue | 6 +++--- .../ChillPersonBundle/Resources/public/vuejs/_js/i18n.js | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index d4bb6a678..7e58ebba8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -132,10 +132,6 @@ const appMessages = { sure_description: "Une fois le changement confirmé, il ne sera plus possible de le remettre à l'état de brouillon !", ok: "Confirmer le parcours" }, - action: { - choose_other_social_issue: "Veuillez choisir un autre problématique", - cancel: "Annuler", - }, // catch errors 'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.", 'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.", diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index e30c90d08..12d6716a4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -27,7 +27,7 @@ :allow-empty="true" :show-labels="false" :loading="issueIsLoading" - :placeholder="$t('action.choose_other_social_issue')" + :placeholder="$t('choose_other_social_issue')" :options="socialIssuesOther" @select="addIssueInList"> @@ -123,7 +123,7 @@ const i18n = { pick_an_action: "Choisir une action d'accompagnement", pick_social_issue_linked_with_action: "Indiquez la problématique sociale liée à l'action d'accompagnement", persons_involved: "Usagers concernés", - + choose_other_social_issue: "Veuillez choisir un autre problématique", } } } @@ -280,4 +280,4 @@ span.badge { grid-area: confirm; } } - \ No newline at end of file + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js index 43224ef6e..627079d3d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_js/i18n.js @@ -38,7 +38,6 @@ const personMessages = { neuter: "Neutre, non binaire", undefined: "Non renseigné" } - }, error_only_one_person: "Une seule personne peut être sélectionnée !" } From 133e4858dcc7f23c9a2bd1fe0f5dad810cff0c3c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 13:54:29 +0100 Subject: [PATCH 14/38] household_member_editor: fix translation for onthefly and address modal, fix button appearance --- .../HouseholdMembersEditor/components/HouseholdAddress.vue | 2 +- .../public/vuejs/HouseholdMembersEditor/js/i18n.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/HouseholdAddress.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/HouseholdAddress.vue index 9b2fe94a0..70716ec81 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/HouseholdAddress.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/HouseholdAddress.vue @@ -3,7 +3,7 @@
  • -
  • diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js index 527f3a7da..5688b4dad 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/js/i18n.js @@ -1,5 +1,6 @@ - -import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n' +import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'; +import { ontheflyMessages } from 'ChillMainAssets/vuejs/OnTheFly/i18n'; +import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n'; const appMessages = { fr: { @@ -84,7 +85,7 @@ const appMessages = { } }; -Object.assign(appMessages.fr, personMessages.fr); +Object.assign(appMessages.fr, personMessages.fr, addressMessages.fr, ontheflyMessages.fr); export { appMessages From 5526790d42ab2c5087c74df575a2a41fc8560610 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 14:49:16 +0100 Subject: [PATCH 15/38] diaplay initialComment on course resume page --- .../translations/messages.fr.yml | 1 + .../views/AccompanyingCourse/index.html.twig | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 78363d080..4ae23f1e3 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -56,6 +56,7 @@ centers: centres Centers: Centres comment: commentaire Comment: Commentaire +Pinned comment: Commentaire épinglé Any comment: Aucun commentaire # comment embeddable diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig index cdd0363b4..215aa90c1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/index.html.twig @@ -78,6 +78,25 @@ {% endif %} + {% if accompanyingCourse.initialComment is not empty %} +
    +

    {{ 'Pinned comment'|trans }}

    +
    + {{ accompanyingCourse.initialComment.content }} + +
    +
    + {% endif %} + {% if accompanyingCourse.scopes is not empty %}

    {{ 'Scopes'|trans }}

    From 985d8f0eae9fc420d56fe1aabb0802742a107102 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 15:31:46 +0100 Subject: [PATCH 16/38] thirdparty form: clean builder, and test if this kind input address --- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 6 ------ .../Resources/views/ThirdParty/_form.html.twig | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index a32c0ade2..29069c67d 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -137,12 +137,6 @@ class ThirdPartyType extends AbstractType ->add('address', PickAddressType::class, [ 'label' => 'Address', ]) - ->add('address2', PickAddressType::class, [ - 'label' => 'Address', - 'use_valid_from' => true, - 'use_valid_to' => true, - 'mapped' => false, - ]) ->add('nameCompany', TextType::class, [ 'label' => 'thirdparty.NameCompany', 'required' => false, diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig index c53764871..6b3133fd5 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig @@ -28,7 +28,9 @@ {{ form_widget(form.activeChildren) }} {% endif %} -{{ form_row(form.address) }} +{% if thirdParty.kind != 'contact' and thirdParty.kind != 'child' %} + {{ form_row(form.address) }} +{% endif %} {{ form_row(form.comment) }} From 52a137ee770fe00ee1f8ab8b2f15953f9783f031 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 15:40:11 +0100 Subject: [PATCH 17/38] thirdparty: no need to burst the code: complete commit 1efdade38 --- CHANGELOG.md | 2 +- .../Resources/views/ThirdParty/index.html.twig | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8003b4a6..ec163f58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ and this project adheres to * concerned groups items (activity, calendar) * accompanyingCourseWork lists * accompanyingCourse lists - +* [acompanyingCourse] add initial comment on Resume page ## Test releases diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig index cb9c4bcf5..66b321504 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig @@ -62,7 +62,3 @@ {% endblock %} {% endembed %} {% endblock %} - -{% block css %} - {{ encore_entry_link_tags('page_3party_3party_index') }} -{% endblock %} From f8071d32c023a4195c7ee6d39098a9c7df4e40d2 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 16:31:16 +0100 Subject: [PATCH 18/38] batch replace/rename initialComment by pinnedComment --- .../Entity/AccompanyingPeriod.php | 16 ++++---- .../AccompanyingCourse/components/Comment.vue | 16 ++++---- .../vuejs/AccompanyingCourse/store/index.js | 6 +-- .../views/AccompanyingCourse/index.html.twig | 8 ++-- .../Tests/Entity/AccompanyingPeriodTest.php | 18 ++++----- .../ChillPersonBundle/chill.api.specs.yaml | 4 +- .../migrations/Version20211213150253.php | 38 +++++++++++++++++++ 7 files changed, 72 insertions(+), 34 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 5b4293226..9c13dcd2f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -186,7 +186,7 @@ class AccompanyingPeriod implements * ) * @Groups({"read"}) */ - private ?Comment $initialComment = null; + private ?Comment $pinnedComment = null; /** * @var string @@ -563,7 +563,7 @@ class AccompanyingPeriod implements public function getComments(): Collection { return $this->comments->filter(function (Comment $c) { - return $c !== $this->initialComment; + return $c !== $this->pinnedComment; }); } @@ -606,9 +606,9 @@ class AccompanyingPeriod implements /** * @Groups({"read"}) */ - public function getInitialComment(): ?Comment + public function getPinnedComment(): ?Comment { - return $this->initialComment; + return $this->pinnedComment; } public function getIntensity(): ?string @@ -1030,17 +1030,17 @@ class AccompanyingPeriod implements /** * @Groups({"write"}) */ - public function setInitialComment(?Comment $comment = null): self + public function setPinnedComment(?Comment $comment = null): self { - if (null !== $this->initialComment) { - $this->removeComment($this->initialComment); + if (null !== $this->pinnedComment) { + $this->removeComment($this->pinnedComment); } if ($comment instanceof Comment) { $this->addComment($comment); } - $this->initialComment = $comment; + $this->pinnedComment = $comment; return $this; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue index 7f5b04f99..5df43cdac 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue @@ -20,10 +20,10 @@ tag-name="textarea"> - {% endif %} - {% if accompanyingCourse.initialComment is not empty %} + {% if accompanyingCourse.pinnedComment is not empty %}

    {{ 'Pinned comment'|trans }}

    - {{ accompanyingCourse.initialComment.content }} + {{ accompanyingCourse.pinnedComment.content }}
    diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 9bbea0f1c..0ecc886f8 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -60,28 +60,28 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $this->assertFalse($period->isClosingAfterOpening()); } - public function testInitialComment() + public function testPinnedComment() { $period = new AccompanyingPeriod(new DateTime()); $comment = new Comment(); $replacingComment = new Comment(); - $period->setInitialComment(null); - $this->assertNull($period->getInitialComment()); + $period->setPinnedComment(null); + $this->assertNull($period->getPinnedComment()); - $period->setInitialComment($comment); - $this->assertSame($period->getInitialComment(), $comment); + $period->setPinnedComment($comment); + $this->assertSame($period->getPinnedComment(), $comment); $this->assertSame($period, $comment->getAccompanyingPeriod()); $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); - $period->setInitialComment($replacingComment); - $this->assertSame($period->getInitialComment(), $replacingComment); + $period->setPinnedComment($replacingComment); + $this->assertSame($period->getPinnedComment(), $replacingComment); $this->assertSame($period, $replacingComment->getAccompanyingPeriod()); $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); $this->assertNull($comment->getAccompanyingPeriod()); - $period->setInitialComment(null); - $this->assertNull($period->getInitialComment()); + $period->setPinnedComment(null); + $this->assertNull($period->getPinnedComment()); $this->assertNull($replacingComment->getAccompanyingPeriod()); $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); } diff --git a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml index 3c49cc264..218904e5e 100644 --- a/src/Bundle/ChillPersonBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillPersonBundle/chill.api.specs.yaml @@ -554,7 +554,7 @@ paths: value: type: accompanying_period id: 2668, - initialComment: + pinnedComment: type: accompanying_period_comment content: > This is my an initial comment. @@ -1139,7 +1139,7 @@ paths: description: "OK" 400: description: "transition cannot be applyed" - + /1.0/person/accompanying-course/{id}/confidential.json: post: tags: diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php b/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php new file mode 100644 index 000000000..fc977165f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php @@ -0,0 +1,38 @@ +addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT fk_e260a8683111d50b'); + $this->addSql('DROP INDEX idx_e260a8683111d50b'); + $this->addSql('ALTER TABLE chill_person_accompanying_period RENAME COLUMN initialcomment_id TO pinnedcomment_id'); + $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868B0804E90 FOREIGN KEY (pinnedcomment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_E260A868B0804E90 ON chill_person_accompanying_period (pinnedcomment_id)'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A868B0804E90'); + $this->addSql('DROP INDEX IDX_E260A868B0804E90'); + $this->addSql('ALTER TABLE chill_person_accompanying_period RENAME COLUMN pinnedcomment_id TO initialcomment_id'); + $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT fk_e260a8683111d50b FOREIGN KEY (initialcomment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX idx_e260a8683111d50b ON chill_person_accompanying_period (initialcomment_id)'); + } +} From f4396459a0126bf1efea612453ed104772c66afa Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 16:42:41 +0100 Subject: [PATCH 19/38] comments: add isPinned() method --- .../ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php index 75d1b2857..7be0eccd1 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php @@ -158,4 +158,9 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface return $this; } + + public function isPinned(): bool + { + return $this->getAccompanyingPeriod()->getPinnedComment() === $this; + } } From d5290e4bdd2e7408aeeb034927e1d951d4ae0fc6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 17:25:39 +0100 Subject: [PATCH 20/38] create comments page, with menu entry, route and template --- .../Controller/AccompanyingCourseController.php | 16 ++++++++++++++++ .../Menu/AccompanyingCourseMenuBuilder.php | 7 +++++++ .../AccompanyingCourse/comment_list.html.twig | 11 +++++++++++ .../translations/messages.fr.yml | 2 ++ 4 files changed, 36 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 7d0e841cf..3de0e30f4 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -216,4 +216,20 @@ class AccompanyingCourseController extends Controller 'accompanying_period_id' => $period->getId(), ]); } + + + + /** + * Comments page of Accompanying Course section. + * + * @Route("/{_locale}/parcours/{accompanying_period_id}/comment", name="chill_person_accompanying_period_comment_list") + * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) + */ + public function commentAction(AccompanyingPeriod $accompanyingCourse): Response + { + return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ + 'accompanyingCourse' => $accompanyingCourse, + ]); + } + } diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index fed840954..60455b201 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -73,6 +73,13 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface ], ]) ->setExtras(['order' => 40]); + $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ + 'route' => 'chill_person_accompanying_period_comment_list', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId(), + ], ]) + ->setExtras(['order' => 50]); + $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); if ($workflow->can($period, 'close')) { diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig new file mode 100644 index 000000000..a81721530 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %} + +{% block title %} + {{ 'Accompanying Course Comment list'|trans }} +{% endblock %} + +{% block content %} +
    +

    {{ block('title') }}

    +
    +{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 4a712633d..152a66ee0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -407,6 +407,8 @@ Choose a person to locate by: Localiser auprès d'un usager concerné Associate at least one member with an household, and set an address to this household: Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage. Locate by: Localiser auprès de fix it: Compléter +Accompanying Course Comment: Commentaire +Accompanying Course Comment list: Commentaires du parcours # Household Household: Ménage From 1fbe0447290334b88268ef75603757e5fff42af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Dec 2021 21:42:29 +0100 Subject: [PATCH 21/38] update schema: an evaluation may be linked to multiple actions --- .../Entity/SocialWork/Evaluation.php | 36 +++++++++++----- .../Entity/SocialWork/SocialAction.php | 1 + .../migrations/Version20211213203147.php | 43 +++++++++++++++++++ 3 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php index aeb8d0a8d..57498e6cb 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php @@ -12,6 +12,8 @@ declare(strict_types=1); namespace Chill\PersonBundle\Entity\SocialWork; use DateInterval; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation as Serializer; @@ -45,12 +47,13 @@ class Evaluation private ?DateInterval $notificationDelay = null; /** - * @ORM\ManyToOne( + * @ORM\ManyToMany( * targetEntity=SocialAction::class, * inversedBy="evaluations" * ) + * @ORM\JoinTable(name="chill_person_social_work_evaluation_action") */ - private ?SocialAction $socialAction = null; + private Collection $socialActions; /** * @ORM\Column(type="json") @@ -59,6 +62,11 @@ class Evaluation */ private array $title = []; + public function __construct() + { + $this->socialActions = new ArrayCollection(); + } + public function getDelay(): ?DateInterval { return $this->delay; @@ -74,11 +82,6 @@ class Evaluation return $this->notificationDelay; } - public function getSocialAction(): ?SocialAction - { - return $this->socialAction; - } - public function getTitle(): array { return $this->title; @@ -91,16 +94,27 @@ class Evaluation return $this; } - public function setNotificationDelay(DateInterval $notificationDelay): self + public function addSocialAction(SocialAction $socialAction): self { - $this->notificationDelay = $notificationDelay; + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions->add($socialAction); + } return $this; } - public function setSocialAction(?SocialAction $socialAction): self + public function removeSocialAction(SocialAction $socialAction): self { - $this->socialAction = $socialAction; + if ($this->socialActions->contains($socialAction)) { + $this->socialActions->remove($socialAction); + } + + return $this; + } + + public function setNotificationDelay(DateInterval $notificationDelay): self + { + $this->notificationDelay = $notificationDelay; return $this; } diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index 64e4e79d8..693a44eee 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -92,6 +92,7 @@ class SocialAction $this->children = new ArrayCollection(); $this->goals = new ArrayCollection(); $this->results = new ArrayCollection(); + $this->evaluations = new ArrayCollection(); } public function addChild(self $child): self diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php b/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php new file mode 100644 index 000000000..863dd8c03 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php @@ -0,0 +1,43 @@ +addSql('CREATE TABLE chill_person_social_work_evaluation_action (evaluation_id INT NOT NULL, socialaction_id INT NOT NULL, PRIMARY KEY(evaluation_id, socialaction_id))'); + $this->addSql('CREATE INDEX IDX_DF34CCFB456C5646 ON chill_person_social_work_evaluation_action (evaluation_id)'); + $this->addSql('CREATE INDEX IDX_DF34CCFB3DC32179 ON chill_person_social_work_evaluation_action (socialaction_id)'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB456C5646 FOREIGN KEY (evaluation_id) REFERENCES chill_person_social_work_evaluation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB3DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + + $this->addSql('INSERT INTO chill_person_social_work_evaluation_action (evaluation_id, socialaction_id) '. + 'SELECT id, socialaction_ID FROM chill_person_social_work_evaluation'); + + $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP CONSTRAINT fk_2e23f3febf32a3da'); + $this->addSql('DROP INDEX idx_2e23f3febf32a3da'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP socialaction_id'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE chill_person_social_work_evaluation_action'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD socialaction_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD CONSTRAINT fk_2e23f3febf32a3da FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX idx_2e23f3febf32a3da ON chill_person_social_work_evaluation (socialaction_id)'); + } +} From be5f54c142c60193eb44ea63f3f3fc679e5e366c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 21:46:11 +0100 Subject: [PATCH 22/38] comments: build list --- .../AccompanyingCourse/comment_list.html.twig | 33 +++++++++++++++++++ .../translations/messages.fr.yml | 1 + 2 files changed, 34 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig index a81721530..6f900dc05 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig @@ -1,5 +1,27 @@ {% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %} +{% macro show_comment(comment, options) %} +
    +
    +
    + {% if options.pinned is defined %} + + {% endif %} + + {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    + {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }} +
    +
      +
    • +
    • +
    +
    +
    +
    {{ comment.content }}
    +
    +
    +{% endmacro %} + {% block title %} {{ 'Accompanying Course Comment list'|trans }} {% endblock %} @@ -7,5 +29,16 @@ {% block content %}

    {{ block('title') }}

    +
    + + {% if accompanyingCourse.pinnedComment %} + {{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} + {% endif %} + + {% for c in accompanyingCourse.comments %} + {{ _self.show_comment(c) }} + {% endfor %} + +
    {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 152a66ee0..250890cd0 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -409,6 +409,7 @@ Locate by: Localiser auprès de fix it: Compléter Accompanying Course Comment: Commentaire Accompanying Course Comment list: Commentaires du parcours +pinned: épinglé # Household Household: Ménage From 8b2a8544b8693cc50f2ff9c4d74f35b1bfe0eba5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Dec 2021 21:58:56 +0100 Subject: [PATCH 23/38] form type and controller, wip --- .../AccompanyingCourseController.php | 22 +++++++++-- .../Form/AccompanyingCourseCommentType.php | 39 +++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 3de0e30f4..dccf780d8 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Form\AccompanyingCourseCommentType; use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; @@ -217,18 +218,31 @@ class AccompanyingCourseController extends Controller ]); } - - /** * Comments page of Accompanying Course section. * - * @Route("/{_locale}/parcours/{accompanying_period_id}/comment", name="chill_person_accompanying_period_comment_list") + * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ - public function commentAction(AccompanyingPeriod $accompanyingCourse): Response + public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { + +/* + $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + + $em = $this->getDoctrine()->getManager(); + $em->persist($comment); + $em->flush(); + + } +*/ return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ 'accompanyingCourse' => $accompanyingCourse, +// 'form' => $form->createView() ]); } diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php new file mode 100644 index 000000000..5d580d325 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php @@ -0,0 +1,39 @@ +add('content', ChillTextareaType::class, []); + } + + /** + * @param OptionsResolver $resolver + * @return void + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefault('class', Comment::class); + } +} From 3d3cc9aeb4a21588fbfce3a11b9ff822dd267132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Dec 2021 22:19:05 +0100 Subject: [PATCH 24/38] fix import --- .../Entity/SocialWork/SocialAction.php | 4 ++-- .../Service/Import/SocialWorkMetadata.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index 693a44eee..391a9ce89 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -46,9 +46,9 @@ class SocialAction private $desactivationDate; /** - * @ORM\OneToMany( + * @ORM\ManyToMany( * targetEntity=Evaluation::class, - * mappedBy="socialAction" + * mappedBy="socialActions" * ) */ private Collection $evaluations; diff --git a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php index a432d6837..53d24c788 100644 --- a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php @@ -192,7 +192,7 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface /** @var Evaluation $eval */ $eval = $this->getOrCreateEntity($this->evaluationRepository, 'title', ['fr' => $evaluationTitle]); $eval->setTitle(['fr' => $evaluationTitle]); - $eval->setSocialAction($socialAction); + $eval->addSocialAction($socialAction); $this->entityManager->persist($eval); @@ -212,7 +212,7 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface $socialAction->addGoal($goal); $goal->addSocialAction($socialAction); - //$this->entityManager->persist($socialAction); + $this->entityManager->persist($socialAction); $this->entityManager->persist($goal); return $goal; @@ -239,7 +239,7 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface } $this->entityManager->persist($result); - //$this->entityManager->persist($socialAction); + $this->entityManager->persist($socialAction); return $result; } @@ -380,8 +380,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface if (null !== $socialAction) { $goal = $this->handleGoal($row[4], $socialAction); - $result = $this->handleResult($row[5], $socialActions['socialAction'], $goal); - $eval = $this->handleEvaluation($row[6], $socialActions['socialAction']); + $result = $this->handleResult($row[5], $socialAction, $goal); + $eval = $this->handleEvaluation($row[6], $socialAction); } $this->entityManager->flush(); From f2fd30b69098bc8c50a7bb8a6cc8ac781d7439d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Dec 2021 22:48:54 +0100 Subject: [PATCH 25/38] add ordering to social issue and social action --- .../Entity/SocialWork/SocialAction.php | 16 +++++++++++ .../Entity/SocialWork/SocialIssue.php | 16 +++++++++++ .../Service/Import/SocialWorkMetadata.php | 21 +++++++++++--- .../migrations/Version20211213213755.php | 28 +++++++++++++++++++ 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index 391a9ce89..d65c1a7c9 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -87,6 +87,11 @@ class SocialAction */ private $title = []; + /** + * @ORM\Column(type="float", name="ordering", options={"default": 0.0}) + */ + private float $ordering = 0.0; + public function __construct() { $this->children = new ArrayCollection(); @@ -95,6 +100,17 @@ class SocialAction $this->evaluations = new ArrayCollection(); } + public function getOrdering(): float + { + return $this->ordering; + } + + public function setOrdering(float $ordering): SocialAction + { + $this->ordering = $ordering; + return $this; + } + public function addChild(self $child): self { if (!$this->children->contains($child)) { diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index b0be1ae00..99f7586c4 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -60,12 +60,28 @@ class SocialIssue */ private $title = []; + /** + * @ORM\Column(type="float", name="ordering", options={"default": 0.0}) + */ + private float $ordering = 0.0; + public function __construct() { $this->children = new ArrayCollection(); $this->socialActions = new ArrayCollection(); } + public function getOrdering(): float + { + return $this->ordering; + } + + public function setOrdering(float $ordering): SocialIssue + { + $this->ordering = $ordering; + return $this; + } + public function addChild(self $child): self { if (!$this->children->contains($child)) { diff --git a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php index 53d24c788..621b97b7e 100644 --- a/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php +++ b/src/Bundle/ChillPersonBundle/Service/Import/SocialWorkMetadata.php @@ -253,6 +253,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface ?string $socialActionTitle, ?string $socialActionChildTitle, SocialIssue $socialIssue, + float $orderingParent, + float $orderingChild, ?SocialAction $previousSocialAction, ?SocialAction $previousSocialActionChild ): array { @@ -271,7 +273,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface ]; $parentIsSame = true; } else { - $return['socialAction'] = $parent = (new SocialAction())->setTitle(['fr' => $socialActionTitle]); + $return['socialAction'] = $parent = (new SocialAction())->setTitle(['fr' => $socialActionTitle]) + ->setOrdering($orderingParent); $parent->setIssue($socialIssue); $this->entityManager->persist($parent); $parentIsSame = false; @@ -284,7 +287,7 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface } else { $return['socialActionChild'] = $child = (new SocialAction())->setTitle(['fr' => $socialActionChildTitle]); $parent->addChild($child); - $child->setIssue($socialIssue); + $child->setIssue($socialIssue)->setOrdering($orderingChild); $this->entityManager->persist($child); } @@ -299,6 +302,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface private function handleSocialIssue( ?string $socialIssueTitle, ?string $socialIssueChildTitle, + float $orderingParent, + float $orderingChild, ?SocialIssue $previousSocialIssue, ?SocialIssue $previousSocialIssueChild ): array { @@ -310,7 +315,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface ]; $parentIsSame = true; } elseif (null !== $socialIssueTitle) { - $return['socialIssue'] = $parent = (new SocialIssue())->setTitle(['fr' => $socialIssueTitle]); + $return['socialIssue'] = $parent = (new SocialIssue())->setTitle(['fr' => $socialIssueTitle]) + ->setOrdering($orderingParent); $this->entityManager->persist($parent); $parentIsSame = false; } else { @@ -323,7 +329,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface if ($parentIsSame && null !== $previousSocialIssueChild && ($previousSocialIssueChild->getTitle()['fr'] === $socialIssueChildTitle)) { $return['socialIssueChild'] = $previousSocialIssueChild; } elseif (null !== $socialIssueChildTitle) { - $return['socialIssueChild'] = $child = (new SocialIssue())->setTitle(['fr' => $socialIssueChildTitle]); + $return['socialIssueChild'] = $child = (new SocialIssue())->setTitle(['fr' => $socialIssueChildTitle]) + ->setOrdering($orderingChild); $parent->addChild($child); $this->entityManager->persist($child); } else { @@ -353,10 +360,14 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface */ private function import1(int $key, array $row, array $previousRow): array { + $baseOrdering = $key * 10.0; + $socialIssues = $this ->handleSocialIssue( $row[0], $row[1], + $key + 1.0, + $key + 3.0, $previousRow['socialIssues']['socialIssue'] ?? null, $previousRow['socialIssues']['socialIssueChild'] ?? null ); @@ -372,6 +383,8 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface $row[2], $row[3], $socialIssue, + $key + 5.0, + $key + 7.0, $previousRow['socialActions']['socialAction'] ?? null, $previousRow['socialActions']['socialActionChild'] ?? null ); diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php b/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php new file mode 100644 index 000000000..b3bb07b89 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php @@ -0,0 +1,28 @@ +addSql('ALTER TABLE chill_person_social_action ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL'); + $this->addSql('ALTER TABLE chill_person_social_issue ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_social_action DROP ordering'); + $this->addSql('ALTER TABLE chill_person_social_issue DROP ordering'); + } +} From f9dd1c52315b83eb9b53478d2d130b7c6e4a1094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Dec 2021 22:57:50 +0100 Subject: [PATCH 26/38] fix cs --- .../Entity/SocialWork/Evaluation.php | 32 +++++++++--------- .../Entity/SocialWork/SocialAction.php | 33 ++++++++++--------- .../Entity/SocialWork/SocialIssue.php | 33 ++++++++++--------- .../migrations/Version20211213203147.php | 27 +++++++++------ .../migrations/Version20211213213755.php | 19 +++++++---- 5 files changed, 80 insertions(+), 64 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php index 57498e6cb..5ee08a15c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php @@ -67,6 +67,15 @@ class Evaluation $this->socialActions = new ArrayCollection(); } + public function addSocialAction(SocialAction $socialAction): self + { + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions->add($socialAction); + } + + return $this; + } + public function getDelay(): ?DateInterval { return $this->delay; @@ -87,22 +96,6 @@ class Evaluation return $this->title; } - public function setDelay(DateInterval $delay): self - { - $this->delay = $delay; - - return $this; - } - - public function addSocialAction(SocialAction $socialAction): self - { - if (!$this->socialActions->contains($socialAction)) { - $this->socialActions->add($socialAction); - } - - return $this; - } - public function removeSocialAction(SocialAction $socialAction): self { if ($this->socialActions->contains($socialAction)) { @@ -112,6 +105,13 @@ class Evaluation return $this; } + public function setDelay(DateInterval $delay): self + { + $this->delay = $delay; + + return $this; + } + public function setNotificationDelay(DateInterval $notificationDelay): self { $this->notificationDelay = $notificationDelay; diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php index d65c1a7c9..ec5e5a8e5 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialAction.php @@ -71,6 +71,11 @@ class SocialAction */ private $issue; + /** + * @ORM\Column(type="float", name="ordering", options={"default": 0.0}) + */ + private float $ordering = 0.0; + /** * @ORM\ManyToOne(targetEntity=SocialAction::class, inversedBy="children") */ @@ -87,11 +92,6 @@ class SocialAction */ private $title = []; - /** - * @ORM\Column(type="float", name="ordering", options={"default": 0.0}) - */ - private float $ordering = 0.0; - public function __construct() { $this->children = new ArrayCollection(); @@ -100,17 +100,6 @@ class SocialAction $this->evaluations = new ArrayCollection(); } - public function getOrdering(): float - { - return $this->ordering; - } - - public function setOrdering(float $ordering): SocialAction - { - $this->ordering = $ordering; - return $this; - } - public function addChild(self $child): self { if (!$this->children->contains($child)) { @@ -216,6 +205,11 @@ class SocialAction return $this->issue; } + public function getOrdering(): float + { + return $this->ordering; + } + public function getParent(): ?self { return $this->parent; @@ -290,6 +284,13 @@ class SocialAction return $this; } + public function setOrdering(float $ordering): SocialAction + { + $this->ordering = $ordering; + + return $this; + } + /** * @internal use $parent->addChild() instead (@see{self::addChild()}) */ diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php index 99f7586c4..c735c0132 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/SocialIssue.php @@ -44,6 +44,11 @@ class SocialIssue */ private $id; + /** + * @ORM\Column(type="float", name="ordering", options={"default": 0.0}) + */ + private float $ordering = 0.0; + /** * @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="children") */ @@ -60,28 +65,12 @@ class SocialIssue */ private $title = []; - /** - * @ORM\Column(type="float", name="ordering", options={"default": 0.0}) - */ - private float $ordering = 0.0; - public function __construct() { $this->children = new ArrayCollection(); $this->socialActions = new ArrayCollection(); } - public function getOrdering(): float - { - return $this->ordering; - } - - public function setOrdering(float $ordering): SocialIssue - { - $this->ordering = $ordering; - return $this; - } - public function addChild(self $child): self { if (!$this->children->contains($child)) { @@ -231,6 +220,11 @@ class SocialIssue return $this->id; } + public function getOrdering(): float + { + return $this->ordering; + } + public function getParent(): ?self { return $this->parent; @@ -321,6 +315,13 @@ class SocialIssue return $this; } + public function setOrdering(float $ordering): SocialIssue + { + $this->ordering = $ordering; + + return $this; + } + /** * @internal use @see{SocialIssue::addChild()} instead */ diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php b/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php index 863dd8c03..53282e83f 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211213203147.php @@ -1,5 +1,12 @@ addSql('DROP TABLE chill_person_social_work_evaluation_action'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD socialaction_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD CONSTRAINT fk_2e23f3febf32a3da FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX idx_2e23f3febf32a3da ON chill_person_social_work_evaluation (socialaction_id)'); + } + public function getDescription(): string { return 'an evaluation may be linked with multiple social actions'; @@ -25,19 +40,11 @@ final class Version20211213203147 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB456C5646 FOREIGN KEY (evaluation_id) REFERENCES chill_person_social_work_evaluation (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation_action ADD CONSTRAINT FK_DF34CCFB3DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('INSERT INTO chill_person_social_work_evaluation_action (evaluation_id, socialaction_id) '. + $this->addSql('INSERT INTO chill_person_social_work_evaluation_action (evaluation_id, socialaction_id) ' . 'SELECT id, socialaction_ID FROM chill_person_social_work_evaluation'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP CONSTRAINT fk_2e23f3febf32a3da'); $this->addSql('DROP INDEX idx_2e23f3febf32a3da'); $this->addSql('ALTER TABLE chill_person_social_work_evaluation DROP socialaction_id'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP TABLE chill_person_social_work_evaluation_action'); - $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD socialaction_id INT DEFAULT NULL'); - $this->addSql('ALTER TABLE chill_person_social_work_evaluation ADD CONSTRAINT fk_2e23f3febf32a3da FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX idx_2e23f3febf32a3da ON chill_person_social_work_evaluation (socialaction_id)'); - } } diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php b/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php index b3bb07b89..347ea35bf 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211213213755.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE chill_person_social_action DROP ordering'); + $this->addSql('ALTER TABLE chill_person_social_issue DROP ordering'); + } + public function getDescription(): string { return 'Add ordering to social issue and social actions'; @@ -19,10 +32,4 @@ final class Version20211213213755 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_social_action ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL'); $this->addSql('ALTER TABLE chill_person_social_issue ADD ordering DOUBLE PRECISION DEFAULT \'0\' NOT NULL'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE chill_person_social_action DROP ordering'); - $this->addSql('ALTER TABLE chill_person_social_issue DROP ordering'); - } } From 530267a9b0d4f1e3a448bf5af8bacb0635449d94 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Dec 2021 10:25:36 +0100 Subject: [PATCH 27/38] commments: add basic form in template --- .../AccompanyingCourseController.php | 10 ++++++---- .../AccompanyingCourse/comment_list.html.twig | 19 +++++++++++++++++++ .../translations/messages.fr.yml | 4 ++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index dccf780d8..4495948fe 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -227,22 +227,24 @@ class AccompanyingCourseController extends Controller public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { -/* - $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); + $comment = new AccompanyingPeriod\Comment(); + $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); + $em->persist($comment); $em->flush(); + return $this->redirectToRoute($route); } -*/ + return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ 'accompanyingCourse' => $accompanyingCourse, -// 'form' => $form->createView() + 'form' => $form->createView() ]); } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig index 6f900dc05..514ca388d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig @@ -29,6 +29,25 @@ {% block content %}

    {{ block('title') }}

    + +
    + {{ form_start(form) }} + {{ form_errors(form) }} + + {{ form_widget(form.content) }} + +
      +
    • + + {# + + #} +
    • +
    + + {{ form_end(form) }} +
    +
    {% if accompanyingCourse.pinnedComment %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 250890cd0..d8da74b14 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -407,9 +407,13 @@ Choose a person to locate by: Localiser auprès d'un usager concerné Associate at least one member with an household, and set an address to this household: Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage. Locate by: Localiser auprès de fix it: Compléter + +# Accompanying Course comments Accompanying Course Comment: Commentaire Accompanying Course Comment list: Commentaires du parcours pinned: épinglé +Post a new comment: Poster un nouveau commentaire +Edit a comment: Modifier le commentaire # Household Household: Ménage From 3c1c07dc6447e93282dd0d057275ee3ac8dbf726 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Dec 2021 10:54:44 +0100 Subject: [PATCH 28/38] comments: edit links with anchor and parameter --- .../Resources/views/AccompanyingCourse/comment_list.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig index 514ca388d..2238b152b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig @@ -7,12 +7,12 @@ {% if options.pinned is defined %} {% endif %} - + {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}
      -
    • +
    From d3127bed6d03a478dab4ef01e59a0cf4806e8177 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Dec 2021 14:57:11 +0100 Subject: [PATCH 29/38] thirdparty: add address on kind = contact --- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 6 +++--- .../Resources/views/ThirdParty/_form.html.twig | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 29069c67d..4146e98a3 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -134,9 +134,6 @@ class ThirdPartyType extends AbstractType // Institutional ThirdParty (parent) } else { $builder - ->add('address', PickAddressType::class, [ - 'label' => 'Address', - ]) ->add('nameCompany', TextType::class, [ 'label' => 'thirdparty.NameCompany', 'required' => false, @@ -164,6 +161,9 @@ class ThirdPartyType extends AbstractType if (ThirdParty::KIND_CHILD !== $options['kind']) { $builder + ->add('address', PickAddressType::class, [ + 'label' => 'Address', + ]) ->add('typesAndCategories', PickThirdPartyTypeCategoryType::class, [ 'label' => 'thirdparty.Categories', ]) diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig index 6b3133fd5..6b76b5cb0 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig @@ -28,7 +28,7 @@ {{ form_widget(form.activeChildren) }} {% endif %} -{% if thirdParty.kind != 'contact' and thirdParty.kind != 'child' %} +{% if form.address is defined %} {{ form_row(form.address) }} {% endif %} From da7bfa8a4efd7d415c9ed6fee96256399e65dc19 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Dec 2021 15:46:55 +0100 Subject: [PATCH 30/38] thirdparty: fix denormalization of thirdparty --- .../Entity/ThirdParty.php | 36 ++++++++-------- .../Tests/Entity/ThirdPartyTest.php | 20 ++++----- .../ThirdPartyJsonDenormalizerTest.php | 43 +++++++++++++++++++ .../ThirdpartyDocGenNormalizerTest.php | 2 - 4 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 069dba9d8..2466f745c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -222,7 +222,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * @var array|null * @ORM\Column(name="types", type="json", nullable=true) */ - private $types; + private ?array $thirdPartyTypes = []; /** * @ORM\Column(name="updated_at", type="datetime_immutable", nullable=true) @@ -303,18 +303,18 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function addType(?string $type): self + public function addThirdPartyTypes(?string $type): self { if (null === $type) { return $this; } - if (!in_array($type, $this->types ?? [], true)) { - $this->types[] = $type; + if (!in_array($type, $this->thirdPartyTypes ?? [], true)) { + $this->thirdPartyTypes[] = $type; } foreach ($this->children as $child) { - $child->addType($type); + $child->addThirdPartyTypes($type); } return $this; @@ -329,7 +329,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface } if (is_string($typeAndCategory)) { - $this->addType($typeAndCategory); + $this->addThirdPartyTypes($typeAndCategory); return $this; } @@ -473,16 +473,16 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * * @return array|null */ - public function getTypes() + public function getThirdPartyTypes() { - return $this->types; + return $this->thirdPartyTypes ?? []; } public function getTypesAndCategories(): array { return array_merge( $this->getCategories()->toArray(), - $this->getTypes() ?? [] + $this->getThirdPartyTypes() ?? [] ); } @@ -574,18 +574,18 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function removeType(?string $type): self + public function removeThirdPartyTypes(?string $type): self { if (null === $type) { return $this; } - if (in_array($type, $this->types ?? [], true)) { - $this->types = array_filter($this->types, fn ($e) => !in_array($e, $this->types, true)); + if (in_array($type, $this->thirdPartyTypes ?? [], true)) { + $this->thirdPartyTypes = array_filter($this->thirdPartyTypes, fn ($e) => !in_array($e, $this->thirdPartyTypes, true)); } foreach ($this->children as $child) { - $child->removeType($type); + $child->removeThirdPartyTypes($type); } return $this; @@ -600,7 +600,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface } if (is_string($typeAndCategory)) { - $this->removeType($typeAndCategory); + $this->removeThirdPartyTypes($typeAndCategory); return $this; } @@ -799,13 +799,13 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface * * @return ThirdParty */ - public function setTypes(?array $type = null) + public function setThirdPartyTypes(?array $type = []) { // remove all keys from the input data - $this->types = array_values($type); + $this->thirdPartyTypes = array_values($type); foreach ($this->children as $child) { - $child->setTypes($type); + $child->setThirdPartyTypes($type); } return $this; @@ -814,7 +814,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface public function setTypesAndCategories(array $typesAndCategories): self { $types = array_filter($typesAndCategories, static fn ($item) => !$item instanceof ThirdPartyCategory); - $this->setTypes($types); + $this->setThirdPartyTypes($types); // handle categories foreach ($typesAndCategories as $t) { diff --git a/src/Bundle/ChillThirdPartyBundle/Tests/Entity/ThirdPartyTest.php b/src/Bundle/ChillThirdPartyBundle/Tests/Entity/ThirdPartyTest.php index 0ec7d065e..4dc6dbc55 100644 --- a/src/Bundle/ChillThirdPartyBundle/Tests/Entity/ThirdPartyTest.php +++ b/src/Bundle/ChillThirdPartyBundle/Tests/Entity/ThirdPartyTest.php @@ -35,8 +35,8 @@ final class ThirdPartyTest extends TestCase $this->assertTrue($tp->getCategories()->contains($cat2)); $this->assertCount(2, $tp->getCategories()); - $this->assertCount(1, $tp->getTypes()); - $this->assertContains('type', $tp->getTypes()); + $this->assertCount(1, $tp->getThirdPartyTypes()); + $this->assertContains('type', $tp->getThirdPartyTypes()); $this->assertCount(3, $tp->getTypesAndCategories()); $this->assertContains($cat1, $tp->getTypesAndCategories()); @@ -54,8 +54,8 @@ final class ThirdPartyTest extends TestCase $this->assertFalse($tp->getCategories()->contains($cat2)); $this->assertCount(1, $tp->getCategories()); - $this->assertCount(0, $tp->getTypes()); - $this->assertNotContains('type', $tp->getTypes()); + $this->assertCount(0, $tp->getThirdPartyTypes()); + $this->assertNotContains('type', $tp->getThirdPartyTypes()); $this->assertCount(1, $tp->getTypesAndCategories()); $this->assertContains($cat1, $tp->getTypesAndCategories()); @@ -77,9 +77,9 @@ final class ThirdPartyTest extends TestCase $this->assertTrue($tp->getCategories()->contains($cat2)); $this->assertCount(2, $tp->getCategories()); - $this->assertCount(2, $tp->getTypes()); - $this->assertContains('type1', $tp->getTypes()); - $this->assertContains('type2', $tp->getTypes()); + $this->assertCount(2, $tp->getThirdPartyTypes()); + $this->assertContains('type1', $tp->getThirdPartyTypes()); + $this->assertContains('type2', $tp->getThirdPartyTypes()); $this->assertCount(4, $tp->getTypesAndCategories()); $this->assertContains($cat1, $tp->getTypesAndCategories()); @@ -93,9 +93,9 @@ final class ThirdPartyTest extends TestCase $this->assertFalse($tp->getCategories()->contains($cat2)); $this->assertCount(1, $tp->getCategories()); - $this->assertCount(1, $tp->getTypes()); - $this->assertContains('type1', $tp->getTypes()); - $this->assertNotContains('type2', $tp->getTypes()); + $this->assertCount(1, $tp->getThirdPartyTypes()); + $this->assertContains('type1', $tp->getThirdPartyTypes()); + $this->assertNotContains('type2', $tp->getThirdPartyTypes()); $this->assertCount(2, $tp->getTypesAndCategories()); $this->assertContains($cat1, $tp->getTypesAndCategories()); diff --git a/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php b/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php new file mode 100644 index 000000000..811b55136 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php @@ -0,0 +1,43 @@ +normalizer = self::$container->get(DenormalizerInterface::class); + } + + public function testDenormalizeContact() + { + $str = <<normalizer->denormalize(json_decode($str, true), ThirdParty::class, 'json', [ + 'groups' => ['write'] + ]); + + $this->assertInstanceOf(ThirdParty::class, $actual); + $this->assertEquals('badaboum', $actual->getName()); + $this->assertEquals('badaboum@email.com', $actual->getEmail()); + $this->assertEquals(ThirdParty::KIND_CONTACT, $actual->getKind()); + } + +} diff --git a/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdpartyDocGenNormalizerTest.php b/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdpartyDocGenNormalizerTest.php index 0b8169d69..cc2b7b33b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdpartyDocGenNormalizerTest.php +++ b/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdpartyDocGenNormalizerTest.php @@ -44,8 +44,6 @@ final class ThirdpartyDocGenNormalizerTest extends KernelTestCase $actual = $this->normalizer->normalize($thirdparty, 'docgen', ['groups' => ['docgen:read']]); - var_dump($actual); - $this->assertIsArray($actual); } } From e71e369f15ea373987e090db86a834f40ab9b3cb Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Dec 2021 18:39:22 +0100 Subject: [PATCH 31/38] temporary disable comment page in menu --- .../ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 60455b201..86418670d 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -73,12 +73,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface ], ]) ->setExtras(['order' => 40]); + /* $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 50]); + */ $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); From 264bd764610ccdeba7af57c1bee74a2f41dec311 Mon Sep 17 00:00:00 2001 From: LenaertsJ Date: Tue, 14 Dec 2021 18:48:31 +0000 Subject: [PATCH 32/38] Issue336 internal create action fixes --- .../AccompanyingCourseController.php | 59 ++++++++-------- .../ORM/LoadAccompanyingPeriodWork.php | 2 +- .../Entity/AccompanyingPeriod.php | 68 +++++++++---------- .../Entity/AccompanyingPeriod/Comment.php | 10 +-- .../ChillPersonBundle/Entity/Person.php | 2 +- .../Entity/SocialWork/Evaluation.php | 5 ++ .../Form/AccompanyingCourseCommentType.php | 4 +- .../Menu/AccompanyingCourseMenuBuilder.php | 2 +- .../AccompanyingCourseWorkCreate/App.vue | 16 +++-- .../AccompanyingCourseWorkCreate/store.js | 16 +---- .../Tests/Entity/AccompanyingPeriodTest.php | 52 +++++++------- .../migrations/Version20211213150253.php | 26 ++++--- .../Entity/ThirdParty.php | 1 - .../ThirdPartyJsonDenormalizerTest.php | 37 ++++++---- 14 files changed, 154 insertions(+), 146 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 4495948fe..78f0bad7e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -110,6 +110,34 @@ class AccompanyingCourseController extends Controller ]); } + /** + * Comments page of Accompanying Course section. + * + * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") + * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) + */ + public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response + { + $comment = new AccompanyingPeriod\Comment(); + + $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + + $em->persist($comment); + $em->flush(); + + return $this->redirectToRoute($route); + } + + return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ + 'accompanyingCourse' => $accompanyingCourse, + 'form' => $form->createView(), + ]); + } + /** * Edit page of Accompanying Course section. * @@ -217,35 +245,4 @@ class AccompanyingCourseController extends Controller 'accompanying_period_id' => $period->getId(), ]); } - - /** - * Comments page of Accompanying Course section. - * - * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") - * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) - */ - public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response - { - - $comment = new AccompanyingPeriod\Comment(); - - $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - - $em = $this->getDoctrine()->getManager(); - - $em->persist($comment); - $em->flush(); - - return $this->redirectToRoute($route); - } - - return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ - 'accompanyingCourse' => $accompanyingCourse, - 'form' => $form->createView() - ]); - } - } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php index 64c7d2701..d34c705ac 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodWork.php @@ -95,7 +95,7 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture // 1 of 10, force an evaluation if (0 === $i % 10) { $evaluation = $this->getRandomEvaluation(); - $action = $evaluation->getSocialAction(); + $action = $evaluation->getSocialActions()->first(); $issue = $action->getIssue(); $period->addSocialIssue($issue); diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 9c13dcd2f..685010836 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -180,14 +180,6 @@ class AccompanyingPeriod implements */ private ?int $id = null; - /** - * @ORM\ManyToOne( - * targetEntity=Comment::class - * ) - * @Groups({"read"}) - */ - private ?Comment $pinnedComment = null; - /** * @var string * @ORM\Column(type="string", nullable=true) @@ -229,6 +221,14 @@ class AccompanyingPeriod implements */ private ?Person $personLocation = null; + /** + * @ORM\ManyToOne( + * targetEntity=Comment::class + * ) + * @Groups({"read"}) + */ + private ?Comment $pinnedComment = null; + /** * @ORM\Column(type="text") * @Groups({"read", "write"}) @@ -603,14 +603,6 @@ class AccompanyingPeriod implements return $this->id; } - /** - * @Groups({"read"}) - */ - public function getPinnedComment(): ?Comment - { - return $this->pinnedComment; - } - public function getIntensity(): ?string { return $this->intensity; @@ -738,6 +730,14 @@ class AccompanyingPeriod implements ); } + /** + * @Groups({"read"}) + */ + public function getPinnedComment(): ?Comment + { + return $this->pinnedComment; + } + /** * @return Collection|SocialAction[] All the descendant social actions of all * the descendants of the entity @@ -1027,24 +1027,6 @@ class AccompanyingPeriod implements return $this; } - /** - * @Groups({"write"}) - */ - public function setPinnedComment(?Comment $comment = null): self - { - if (null !== $this->pinnedComment) { - $this->removeComment($this->pinnedComment); - } - - if ($comment instanceof Comment) { - $this->addComment($comment); - } - - $this->pinnedComment = $comment; - - return $this; - } - public function setIntensity(string $intensity): self { $this->intensity = $intensity; @@ -1083,6 +1065,24 @@ class AccompanyingPeriod implements return $this; } + /** + * @Groups({"write"}) + */ + public function setPinnedComment(?Comment $comment = null): self + { + if (null !== $this->pinnedComment) { + $this->removeComment($this->pinnedComment); + } + + if ($comment instanceof Comment) { + $this->addComment($comment); + } + + $this->pinnedComment = $comment; + + return $this; + } + public function setRemark(?string $remark = null): self { $this->remark = (string) $remark; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php index 7be0eccd1..105633e43 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php @@ -112,6 +112,11 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface return $this->updatedBy; } + public function isPinned(): bool + { + return $this->getAccompanyingPeriod()->getPinnedComment() === $this; + } + public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self { $this->accompanyingPeriod = $accompanyingPeriod; @@ -158,9 +163,4 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface return $this; } - - public function isPinned(): bool - { - return $this->getAccompanyingPeriod()->getPinnedComment() === $this; - } } diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index a3524d306..882be10ed 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -244,7 +244,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * @Assert\Date( * groups={"general", "creation"} * ) - * @Assert\GreaterThan(propertyPath="birthDate") + * @Assert\GreaterThanOrEqual(propertyPath="birthdate") * @Assert\LessThanOrEqual("today") */ private ?DateTimeImmutable $deathdate = null; diff --git a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php index 5ee08a15c..1350ae6d8 100644 --- a/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/SocialWork/Evaluation.php @@ -91,6 +91,11 @@ class Evaluation return $this->notificationDelay; } + public function getSocialActions(): Collection + { + return $this->socialActions; + } + public function getTitle(): array { return $this->title; diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php index 5d580d325..b123a4c4d 100644 --- a/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php +++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseCommentType.php @@ -1,4 +1,5 @@ $period->getId(), ], ]) ->setExtras(['order' => 50]); - */ + */ $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue index 12d6716a4..2cbc0cdac 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/App.vue @@ -8,10 +8,10 @@

    {{ $t('pick_social_issue_linked_with_action') }}

    - {{ si.text }} + {{ si.text }}
    -
    +

    {{ $t('pick_an_action') }}

    -
    +
    {{ $t('form_has_errors') }}

      -
    • +
    • {{ e }}
    @@ -120,6 +120,7 @@ const i18n = { endDate: "Date de fin", form_has_errors: "Le formulaire comporte des erreurs", pick_social_issue: "Choisir une problématique sociale", + pick_other_social_issue: "Veuillez choisir un autre problématique", pick_an_action: "Choisir une action d'accompagnement", pick_social_issue_linked_with_action: "Indiquez la problématique sociale liée à l'action d'accompagnement", persons_involved: "Usagers concernés", @@ -178,12 +179,10 @@ export default { personsPicked: { get() { let s = this.$store.state.personsPicked.map(p => p.id); - // console.log('persons picked', s); return s; }, set(v) { - // console.log('persons picked', v); this.$store.commit('setPersonsPickedIds', v); } }, @@ -226,6 +225,11 @@ export default { this.$store.commit('setEndDate', ISOToDate(value)); } }, + setSocialIssue: { + set() { + this.$store.dispatch('setSocialIssue', socialIssues[socialIssues.length - 1]) + } + } } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js index 8633c003d..408115257 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkCreate/store.js @@ -31,7 +31,6 @@ const store = createStore({ return null !== state.socialActionPicked; }, hasSocialIssuePicked(state) { - console.log(state.socialIssuePicked); return null !== state.socialIssuePicked; }, isLoadingSocialActions(state) { @@ -74,36 +73,27 @@ const store = createStore({ }, mutations: { setSocialActionsReachables(state, actions) { - // console.log('set social action reachables'); - // console.log(actions); - state.socialActionsReachables = actions; }, setSocialAction(state, socialAction) { - // console.log('socialAction', socialAction); state.socialActionPicked = socialAction; }, setSocialIssue(state, socialIssueId) { - // console.log('set social issue', socialIssueId); if (socialIssueId === null) { state.socialIssuePicked = null; } else { let mapped = state.socialIssues .find(e => e.id === socialIssueId); state.socialIssuePicked = mapped; - // console.log('social issue setted', state.socialIssuePicked); } }, addIssueInList(state, issue) { - //console.log('add issue list', issue.id); state.socialIssues.push(issue); }, updateIssuesOther(state, payload) { - //console.log('update issues other'); state.socialIssuesOther = payload; }, removeIssueInOther(state, issue) { - //console.log('remove issue other', issue.id); state.socialIssuesOther = state.socialIssuesOther.filter( (i) => i.id !== issue.id ); @@ -124,12 +114,12 @@ const store = createStore({ state.endDate = date; }, setPersonsPickedIds(state, ids) { - console.log('persons ids', ids); + state.personsPicked = state.personsReachables .filter(p => ids.includes(p.id)) }, addErrors(state, { errors, cancel_posting }) { - console.log('add errors', errors); + state.errors = errors; if (cancel_posting) { state.isPostingWork = false; @@ -138,8 +128,6 @@ const store = createStore({ }, actions: { pickSocialIssue({ commit }, socialIssueId) { - console.log('pick social issue'); - commit('setIsLoadingSocialActions', true); commit('setSocialAction', null); commit('setSocialActionsReachables', []); diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 0ecc886f8..a459c3c18 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -60,32 +60,6 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $this->assertFalse($period->isClosingAfterOpening()); } - public function testPinnedComment() - { - $period = new AccompanyingPeriod(new DateTime()); - $comment = new Comment(); - $replacingComment = new Comment(); - - $period->setPinnedComment(null); - $this->assertNull($period->getPinnedComment()); - - $period->setPinnedComment($comment); - $this->assertSame($period->getPinnedComment(), $comment); - $this->assertSame($period, $comment->getAccompanyingPeriod()); - $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); - - $period->setPinnedComment($replacingComment); - $this->assertSame($period->getPinnedComment(), $replacingComment); - $this->assertSame($period, $replacingComment->getAccompanyingPeriod()); - $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); - $this->assertNull($comment->getAccompanyingPeriod()); - - $period->setPinnedComment(null); - $this->assertNull($period->getPinnedComment()); - $this->assertNull($replacingComment->getAccompanyingPeriod()); - $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); - } - public function testIsClosed() { $period = new AccompanyingPeriod(new DateTime()); @@ -145,6 +119,32 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase $this->assertEquals(1, $period->getParticipationsContainsPerson($person4)->count()); } + public function testPinnedComment() + { + $period = new AccompanyingPeriod(new DateTime()); + $comment = new Comment(); + $replacingComment = new Comment(); + + $period->setPinnedComment(null); + $this->assertNull($period->getPinnedComment()); + + $period->setPinnedComment($comment); + $this->assertSame($period->getPinnedComment(), $comment); + $this->assertSame($period, $comment->getAccompanyingPeriod()); + $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); + + $period->setPinnedComment($replacingComment); + $this->assertSame($period->getPinnedComment(), $replacingComment); + $this->assertSame($period, $replacingComment->getAccompanyingPeriod()); + $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); + $this->assertNull($comment->getAccompanyingPeriod()); + + $period->setPinnedComment(null); + $this->assertNull($period->getPinnedComment()); + $this->assertNull($replacingComment->getAccompanyingPeriod()); + $this->assertEquals(0, count($period->getComments()), 'The initial comment should not appears in the list of comments'); + } + public function testRequestor() { $period = new AccompanyingPeriod(new DateTime()); diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php b/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php index fc977165f..f02ad75b0 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20211213150253.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A868B0804E90'); + $this->addSql('DROP INDEX IDX_E260A868B0804E90'); + $this->addSql('ALTER TABLE chill_person_accompanying_period RENAME COLUMN pinnedcomment_id TO initialcomment_id'); + $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT fk_e260a8683111d50b FOREIGN KEY (initialcomment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX idx_e260a8683111d50b ON chill_person_accompanying_period (initialcomment_id)'); + } + public function getDescription(): string { return 'rename initialComment attribute to pinnedComment'; @@ -26,13 +41,4 @@ final class Version20211213150253 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT FK_E260A868B0804E90 FOREIGN KEY (pinnedcomment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); $this->addSql('CREATE INDEX IDX_E260A868B0804E90 ON chill_person_accompanying_period (pinnedcomment_id)'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE chill_person_accompanying_period DROP CONSTRAINT FK_E260A868B0804E90'); - $this->addSql('DROP INDEX IDX_E260A868B0804E90'); - $this->addSql('ALTER TABLE chill_person_accompanying_period RENAME COLUMN pinnedcomment_id TO initialcomment_id'); - $this->addSql('ALTER TABLE chill_person_accompanying_period ADD CONSTRAINT fk_e260a8683111d50b FOREIGN KEY (initialcomment_id) REFERENCES chill_person_accompanying_period_comment (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX idx_e260a8683111d50b ON chill_person_accompanying_period (initialcomment_id)'); - } } diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 2466f745c..06b0dddbc 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -219,7 +219,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface private ?string $telephone = null; /** - * @var array|null * @ORM\Column(name="types", type="json", nullable=true) */ private ?array $thirdPartyTypes = []; diff --git a/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php b/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php index 811b55136..611a0d7c7 100644 --- a/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php +++ b/src/Bundle/ChillThirdPartyBundle/Tests/Serializer/Normalizer/ThirdPartyJsonDenormalizerTest.php @@ -1,13 +1,25 @@ normalizer->denormalize(json_decode($str, true), ThirdParty::class, 'json', [ - 'groups' => ['write'] + 'groups' => ['write'], ]); $this->assertInstanceOf(ThirdParty::class, $actual); @@ -39,5 +51,4 @@ class ThirdPartyJsonDenormalizerTest extends KernelTestCase $this->assertEquals('badaboum@email.com', $actual->getEmail()); $this->assertEquals(ThirdParty::KIND_CONTACT, $actual->getKind()); } - } From de790d11a835d84906f369390a91d3490dd869a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 14 Dec 2021 23:20:47 +0100 Subject: [PATCH 33/38] activity/location: refactor Refactor the way for loading locations: * fix showing the default location * fix when there is not thirdparty default location * separate api queries instead of inlines; * use the store instead of the mounted * refactored for a possible re-use in calendar --- .../vuejs/Activity/components/Location.vue | 116 +---------------- .../Resources/public/vuejs/Activity/store.js | 7 + .../public/vuejs/Activity/store.locations.js | 123 ++++++++++++++++++ .../Resources/public/vuejs/Calendar/store.js | 12 +- 4 files changed, 139 insertions(+), 119 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue index c9231006b..50eb14799 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue @@ -15,7 +15,7 @@ :searchable="true" :placeholder="$t('activity.choose_location')" :custom-label="customLabel" - :options="locations" + :options="availableLocations" group-values="locations" group-label="locationGroup" v-model="location" @@ -40,13 +40,8 @@ export default { NewLocation, VueMultiselect, }, - data() { - return { - locations: [], - }; - }, computed: { - ...mapState(["activity"]), + ...mapState(["activity", "availableLocations"]), ...mapGetters(["suggestedEntities"]), location: { get() { @@ -57,61 +52,6 @@ export default { }, }, }, - mounted() { - getLocations().then( - (results) => { - getUserCurrentLocation().then( - userCurrentLocation => { - getLocationTypeByDefaultFor('person').then( - (personLocationType) => { - if (personLocationType) { - const personLocation = this.makeAccompanyingPeriodLocation(personLocationType); - const concernedPersonsLocation = - this.makeConcernedPersonsLocation(personLocationType); - getLocationTypeByDefaultFor('thirdparty').then( - thirdpartyLocationType => { - const concernedThirdPartiesLocation = - this.makeConcernedThirdPartiesLocation(thirdpartyLocationType); - this.locations = [ - { - locationGroup: 'Ma localisation', - locations: [userCurrentLocation] - }, - { - locationGroup: 'Localisation du parcours', - locations: [personLocation] - }, - { - locationGroup: 'Parties concernées', - locations: [...concernedPersonsLocation, ...concernedThirdPartiesLocation] - }, - { - locationGroup: 'Autres localisations', - locations: results - } - ]; - } - ) - } else { - this.locations = [ - { - locationGroup: 'Localisations', - locations: response.results - } - ]; - } - if (window.default_location_id) { - let location = this.locations.filter( - (l) => l.id === window.default_location_id - ); - this.$store.dispatch("updateLocation", location); - } - } - ) - } - ) - }) - }, methods: { labelAccompanyingCourseLocation(value) { return `${value.address.text} (${value.locationType.title.fr})` @@ -125,58 +65,6 @@ export default { : value.locationType.title.fr : ''; }, - makeConcernedPersonsLocation(locationType) { - let locations = []; - this.suggestedEntities.forEach( - (e) => { - if (e.type === 'person' && e.current_household_address !== null){ - locations.push({ - type: 'location', - id: -this.suggestedEntities.indexOf(e)*10, - onthefly: true, - name: e.text, - address: { - id: e.current_household_address.address_id, - }, - locationType: locationType - }); - } - } - ) - return locations; - }, - makeConcernedThirdPartiesLocation(locationType) { - let locations = []; - this.suggestedEntities.forEach( - (e) => { - if (e.type === 'thirdparty' && e.address !== null){ - locations.push({ - type: 'location', - id: -this.suggestedEntities.indexOf(e)*10, - onthefly: true, - name: e.text, - address: { id: e.address.address_id }, - locationType: locationType - }); - } - } - ) - return locations; - }, - makeAccompanyingPeriodLocation(locationType) { - const accPeriodLocation = this.activity.accompanyingPeriod.location; - return { - type: 'location', - id: -1, - onthefly: true, - name: '__AccompanyingCourseLocation__', - address: { - id: accPeriodLocation.address_id, - text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}` - }, - locationType: locationType - } - } }, }; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index 1ca9f9cc2..4bf70b006 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -1,6 +1,7 @@ import 'es6-promise/auto'; import { createStore } from 'vuex'; import { postLocation } from './api'; +import prepareLocations from './store.locations.js'; const debug = process.env.NODE_ENV !== 'production'; //console.log('window.activity', window.activity); @@ -25,6 +26,7 @@ const store = createStore({ activity: window.activity, socialIssuesOther: [], socialActionsList: [], + availableLocations: [], }, getters: { suggestedEntities(state) { @@ -200,6 +202,9 @@ const store = createStore({ console.log("### mutation: updateLocation", value); state.activity.location = value; }, + addAvailableLocationGroup(state, group) { + state.availableLocations.push(group); + } }, actions: { addIssueSelected({ commit }, issue) { @@ -335,4 +340,6 @@ const store = createStore({ }, }); +prepareLocations(store); + export default store; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js new file mode 100644 index 000000000..311bdc219 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -0,0 +1,123 @@ +import {getLocations, getLocationTypeByDefaultFor, getUserCurrentLocation} from "./api"; + +const makeConcernedPersonsLocation = (locationType, store) => { + let locations = []; + store.getters.suggestedEntities.forEach( + (e) => { + if (e.type === 'person' && e.current_household_address !== null){ + locations.push({ + type: 'location', + id: -store.getters.suggestedEntities.indexOf(e)*10, + onthefly: true, + name: e.text, + address: { + id: e.current_household_address.address_id, + }, + locationType: locationType + }); + } + } + ) + return locations; +}; +const makeConcernedThirdPartiesLocation = (locationType, store) => { + let locations = []; + store.getters.suggestedEntities.forEach( + (e) => { + if (e.type === 'thirdparty' && e.address !== null){ + locations.push({ + type: 'location', + id: -store.getters.suggestedEntities.indexOf(e)*10, + onthefly: true, + name: e.text, + address: { id: e.address.address_id }, + locationType: locationType + }); + } + } + ) + return locations; +}; +const makeAccompanyingPeriodLocation = (locationType, store) => { + const accPeriodLocation = store.state.activity.accompanyingPeriod.location; + return { + type: 'location', + id: -1, + onthefly: true, + name: '__AccompanyingCourseLocation__', + address: { + id: accPeriodLocation.address_id, + text: `${accPeriodLocation.text} - ${accPeriodLocation.postcode.code} ${accPeriodLocation.postcode.name}` + }, + locationType: locationType + } +}; + +export default function prepareLocations(store) { + +// find the locations + let allLocations = getLocations().then( + (results) => { + store.commit('addAvailableLocationGroup', { + locationGroup: 'Autres localisations', + locations: results + }); + } + ); + + let currentLocation = getUserCurrentLocation().then( + userCurrentLocation => { + if (null !== userCurrentLocation) { + store.commit('addAvailableLocationGroup', { + locationGroup: 'Ma localisation', + locations: [userCurrentLocation] + }); + } + } + ); + + let partiesLocations = [], partyPromise; + ['person', 'thirdparty'].forEach(kind => { + partyPromise = getLocationTypeByDefaultFor(kind).then( + (kindLocationType) => { + if (kindLocationType) { + let concernedKindLocations; + if (kind === 'person') { + concernedKindLocations = makeConcernedPersonsLocation(kindLocationType, store); + // add location for the parcours into suggestions + const personLocation = makeAccompanyingPeriodLocation(kindLocationType, store); + store.commit('addAvailableLocationGroup', { + locationGroup: 'Localisation du parcours', + locations: [personLocation] + }); + } else { + concernedKindLocations = makeConcernedThirdPartiesLocation(kindLocationType, store); + } + + store.commit('addAvailableLocationGroup', { + locationGroup: kind === 'person' ? 'Usagers concernés' : 'Tiers concernés', + locations: concernedKindLocations, + }); + } + } + ); + partiesLocations.push(partyPromise); + }); + +// when all location are loaded + Promise.all([allLocations, currentLocation, ...partiesLocations]).then(() => { + console.log('current location in activity', store.state.activity.location); + console.log('default loation id', window.default_location_id); + if (window.default_location_id) { + for (let group of store.state.availableLocations) { + console.log(group); + let location = group.locations.find((l) => l.id === window.default_location_id); + console.log(location); + if (location !== undefined) { + store.dispatch('updateLocation', location); + break; + } + } + } + }); +} diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js index edfb7f236..db2950bd4 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store.js @@ -1,6 +1,10 @@ import 'es6-promise/auto'; import { createStore } from 'vuex'; import { postLocation } from 'ChillActivityAssets/vuejs/Activity/api'; +import { + getLocations, getLocationTypeByDefaultFor, + getUserCurrentLocation +} from "../../../../../ChillActivityBundle/Resources/public/vuejs/Activity/api"; const debug = process.env.NODE_ENV !== 'production'; @@ -82,7 +86,7 @@ const store = createStore({ } }, mutations: { - + // ConcernedGroups addPersonsInvolved(state, payload) { //console.log('### mutation addPersonsInvolved', payload.result.type); @@ -94,7 +98,7 @@ const store = createStore({ state.activity.thirdParties.push(payload.result); break; case 'user': - state.activity.users.push(payload.result); + state.activity.users.push(payload.result); break; }; }, @@ -108,7 +112,7 @@ const store = createStore({ state.activity.thirdParties = state.activity.thirdParties.filter(thirdparty => thirdparty !== payload); break; case 'user': - state.activity.users = state.activity.users.filter(user => user !== payload); + state.activity.users = state.activity.users.filter(user => user !== payload); break; }; }, @@ -217,9 +221,7 @@ const store = createStore({ hiddenLocation.value = value.id; } commit("updateLocation", value); - } - } }); From 48f62a2a17f86ee1f6f2abfd8892a495864cfae7 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 15 Dec 2021 00:14:31 +0100 Subject: [PATCH 34/38] refund template design for person household_history --- .../views/Household/summary.html.twig | 4 +- .../views/Person/household_history.html.twig | 295 +++++++++--------- 2 files changed, 143 insertions(+), 156 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig index 3567d1f7e..e88e07013 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/summary.html.twig @@ -133,7 +133,7 @@ {% macro customButtons(member, household) %}
  • + class="btn btn-sm btn-misc" title="{{ 'household.person.leave'|trans }}">
  • diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/household_history.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/household_history.html.twig index 5dff4b074..d75106132 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/household_history.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/household_history.html.twig @@ -4,176 +4,163 @@ {% block title 'household.Household history for person'|trans %} +{% macro bloc_content(p) %} +
    +
    + +
    +
    + {% if p.endDate %} +
    + Jusqu'au {{ p.endDate|format_date('long') }} +
    + {% endif %} +
    +
    +
    +
    +
    +
    +
    +

    En tant que

    +
    +
    +

    {{ p.position.label|localize_translatable_string }} + {% if p.holder %} + {{ 'household.holder'|trans }} + {% endif %} +

    +
    +
    +
    +
    +

    {{ 'household.Members at same time'|trans }}

    +
    +
    + {% set simultaneous = p.household.getMembersDuringMembership(p) %} + {% if simultaneous|length == 0 %} +

    + {{ 'household.Any simultaneous members'|trans }} +

    + {% else %} + {% for m in simultaneous -%} + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: m.person.id }, + buttonText: m.person|chill_entity_render_string + } %} + {%- endfor -%} + {% endif %} +
    +
    +
    +
    +{% endmacro %} + {% block personcontent %}
    +

    {{ 'household.Household history'|trans }}

    -

    {{ 'household.Household history'|trans }}

    -

    {{ 'household.Household shared'|trans }}

    +
    +

    {{ 'household.Household shared'|trans }}

    + {% set memberships = person.getHouseholdParticipationsShareHousehold() %} - {% set memberships = person.getHouseholdParticipationsShareHousehold() %} + {% if memberships|length == 0 %} +

    {{ 'household.Never in any household'|trans }}

    - {% if memberships|length == 0 %} -

    {{ 'household.Never in any household'|trans }}

    + + {% else %} +
    + {% for p in memberships %} +
    + + {{ _self.bloc_content(p) }} + +
    + +
    + +
    + {% endfor %} +
    + + {% if not person.isSharingHousehold() %} - - {% else %} - -
    -
    - - {% if not person.isSharingHousehold() %} - - {% endif %} - - {% for p in memberships %} -
    -
    -
    -
    - {{ p.startDate|format_date('long') }} -
    -
    -
    -
    -
    - -
    -
    -

    - - - {{ 'household.Household number'|trans({'household_num': p.household.id }) }} - -

    -

    {{ p.position.label|localize_translatable_string }} {% if p.holder %}{{ 'household.holder'|trans }}{% endif %} -

    -
    - {% set simultaneous = p.household.getMembersDuringMembership(p) %} - {% if simultaneous|length == 0 %} -

    - {{ 'household.Any simultaneous members'|trans }} -

    - {% else %} - {{ 'household.Members at same time'|trans }}: - {% for p in simultaneous -%} - {{- p.person|chill_entity_render_box({'addLink': true }) -}} - {%- if p.holder %} {{'household.holder'|trans }} {% endif %} - {%- if not loop.last %}, {% endif -%} - {%- endfor -%} - {% endif %} - -
    -
    -
    -
    -
    - {% endfor %} -
    - -
    {% endif %} -

    {{ 'household.Household not shared'|trans }}

    + {% endif %} - {% set memberships = person.getHouseholdParticipationsNotShareHousehold() %} +
    +
    + {% set memberships = person.getHouseholdParticipationsNotShareHousehold() %} + {% if memberships|length > 0 %} - {% if memberships|length == 0 %} -

    {{ 'household.Never in any household'|trans }}

    - {% else %} - - - - - - - - - - {% for p in memberships %} - - - - - - - {% endfor %} - -
    {{ 'household.from'|trans }}{{ 'household.to'|trans }}{{ 'household.Household'|trans }}
    {{ p.startDate|format_date('long') }} - {% if p.endDate is not empty %} - {{ p.endDate|format_date('long') }} - {% else %} - {{ 'household.Membership currently running'|trans }} - {% endif %} - -
    -

    - - - {{ 'household.Household number'|trans({'household_num': p.household.id }) }} - -

    -

    - {{ p.position.label|localize_translatable_string }} - {% if p.holder %} - {{ 'household.holder'|trans }} - {% endif %} -

    -
    - {% set simultaneous = p.household.getMembersDuringMembership(p) %} - {% if simultaneous|length == 0 %} -

    - {{ 'household.Any simultaneous members'|trans }} -

    - {% else %} - {{ 'household.Members at same time'|trans }}: - {% for p in simultaneous -%} - {{- p.person|chill_entity_render_box({'addLink': true }) -}} - {%- if p.holder %} {{'household.holder'|trans }} {% endif %} - {%- if not loop.last %}, {% endif -%} - {%- endfor -%} - {% endif %} -
    -
    - -
    - {% endif %} +

    {{ 'household.Household not shared'|trans }}

    + +
    + {% for p in memberships %} +
    + + {{ _self.bloc_content(p) }} + +
    +
      +
    • + +
    • +
    +
    + +
    + {% endfor %} +
    + {% endif %} +
    {% endblock %} From ecbe30ae53c6f882def046181d37e1be903b618f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Dec 2021 14:21:31 +0100 Subject: [PATCH 35/38] person create button style changed to full width + update changelog --- CHANGELOG.md | 1 + .../Resources/public/chill/scss/record_actions.scss | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d828fd44c..3637de1b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to * accompanyingCourseWork lists * accompanyingCourse lists * [acompanyingCourse] add initial comment on Resume page +* [person] create button full width (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/330) ## Test releases diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss index bdb3c60a6..18ebe4a59 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss @@ -33,6 +33,13 @@ ul.record_actions { margin-right: auto; } } + + ul.dropdown-menu { + li { + display: block; + margin-right: 0; + } + } } .sticky-form-buttons { margin-top: 4em; From f01b87b348a58a1eb1d9650bd006837d44d08c41 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 15 Dec 2021 23:13:20 +0100 Subject: [PATCH 36/38] comments: form controller --- .../AccompanyingCourseCommentController.php | 86 ++++++++++++++++++ .../AccompanyingCourseController.php | 29 ------ .../Menu/AccompanyingCourseMenuBuilder.php | 2 - .../AccompanyingCourse/comment_list.html.twig | 91 ++++++++++++------- .../translations/messages.fr.yml | 1 + 5 files changed, 147 insertions(+), 62 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php new file mode 100644 index 000000000..c5b8ed878 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseCommentController.php @@ -0,0 +1,86 @@ +setAccompanyingPeriod($accompanyingCourse); + + $form = $this->createCommentForm($newComment, 'new'); + + if ($request->query->has('edit')) { + foreach ($accompanyingCourse->getComments() as $comment) { + if ($comment->getId() === $request->query->getInt('edit')) { + $editForm = $this->createCommentForm($comment, 'edit'); + $commentEditId = $comment->getId(); + } + } + $pinnedComment = $accompanyingCourse->getPinnedComment(); + if ($pinnedComment->getId() === $request->query->getInt('edit')) { + $editForm = $this->createCommentForm($pinnedComment, 'edit'); + $commentEditId = $pinnedComment->getId(); + } + } + + if ($request->getMethod() === Request::METHOD_POST) { + if (array_key_exists('edit', $request->request->all()[$editForm->getName()])) { + $currentForm = $editForm->handleRequest($request); + $isEditingNew = false; + } else { + $currentForm = $form->handleRequest($request); + $isEditingNew = true; + } + + if ($currentForm->isSubmitted() && $currentForm->isValid()) { + $em = $this->getDoctrine()->getManager(); + if ($isEditingNew) { + $em->persist($newComment); + } + $em->flush(); + } + + return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [ + 'accompanying_period_id' => $accompanyingCourse->getId() + ]); + } + + return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ + 'accompanyingCourse' => $accompanyingCourse, + 'form' => $form->createView(), + 'edit_form' => isset($editForm) ? $editForm->createView() : null, + 'commentEditId' => $commentEditId ?? null, + ]); + } + + private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface + { + $form = $this->createForm(AccompanyingCourseCommentType::class, $comment); + + if ('edit' === $step) { + $form->add('edit', HiddenType::class, ['mapped' => false ]); + } + + return $form; + } +} diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 78f0bad7e..7d0e841cf 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Controller; use Chill\ActivityBundle\Entity\Activity; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; -use Chill\PersonBundle\Form\AccompanyingCourseCommentType; use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; @@ -110,34 +109,6 @@ class AccompanyingCourseController extends Controller ]); } - /** - * Comments page of Accompanying Course section. - * - * @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list") - * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) - */ - public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response - { - $comment = new AccompanyingPeriod\Comment(); - - $form = $this->createForm(AccompanyingCourseCommentType::class, $comment, []); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); - - $em->persist($comment); - $em->flush(); - - return $this->redirectToRoute($route); - } - - return $this->render('@ChillPerson/AccompanyingCourse/comment_list.html.twig', [ - 'accompanyingCourse' => $accompanyingCourse, - 'form' => $form->createView(), - ]); - } - /** * Edit page of Accompanying Course section. * diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 6c34c8a2e..60455b201 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -73,14 +73,12 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface ], ]) ->setExtras(['order' => 40]); - /* $menu->addChild($this->translator->trans('Accompanying Course Comment'), [ 'route' => 'chill_person_accompanying_period_comment_list', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), ], ]) ->setExtras(['order' => 50]); - */ $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig index 2238b152b..9fc9a1c77 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/comment_list.html.twig @@ -1,63 +1,92 @@ {% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %} +{% block title %} + {{ 'Accompanying Course Comment list'|trans }} +{% endblock %} + {% macro show_comment(comment, options) %}
    {% if options.pinned is defined %} - + {% endif %} {{ 'by'|trans }}{{ comment.creator }}{{ ', ' ~ 'on'|trans ~ ' ' ~ comment.createdAt|format_date('long') }}
    {{ 'Last updated on'|trans ~ ' ' ~ comment.updatedAt|format_datetime('long', 'short') }}
      -
    • -
    • + {% if options.pinned is not defined %} +
    • + +
    • + {% endif %} +
    • + +
    • +
    • + +
    -
    {{ comment.content }}
    +
    {{ comment.content|chill_markdown_to_html }}
    {% endmacro %} -{% block title %} - {{ 'Accompanying Course Comment list'|trans }} -{% endblock %} +{% macro form_comment(type, form) %} + {% if type == 'edit' %} +
    +
    + {% endif %} + {{ form_start(form) }} + {{ form_errors(form) }} + {{ form_widget(form.content) }} +
      +
    • + {% if type == 'new' %} + + {% elseif type == 'edit' %} + + {% endif %} +
    • +
    + {{ form_end(form) }} + {% if type == 'edit' %} +
    +
    + {% endif %} +{% endmacro %} {% block content %}

    {{ block('title') }}

    - -
    - {{ form_start(form) }} - {{ form_errors(form) }} - - {{ form_widget(form.content) }} - -
      -
    • - - {# - - #} -
    • -
    - - {{ form_end(form) }} -
    -
    - {% if accompanyingCourse.pinnedComment %} - {{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} + {% if commentEditId == accompanyingCourse.pinnedComment.id %} + {{ _self.form_comment('edit', edit_form) }} + {% else %} + {{ _self.show_comment(accompanyingCourse.pinnedComment, {'pinned': 'true'}) }} + {% endif %} {% endif %} - {% for c in accompanyingCourse.comments %} - {{ _self.show_comment(c) }} + {% if commentEditId == c.id %} + {{ _self.form_comment('edit', edit_form) }} + {% else %} + {{ _self.show_comment(c) }} + {% endif %} {% endfor %} - +
    +
    +

    {{ 'Write a new comment'|trans }}

    + {{ _self.form_comment('new', form) }}
    {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index d8da74b14..f461e5bec 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -413,6 +413,7 @@ Accompanying Course Comment: Commentaire Accompanying Course Comment list: Commentaires du parcours pinned: épinglé Post a new comment: Poster un nouveau commentaire +Write a new comment: Écrire un nouveau commentaire Edit a comment: Modifier le commentaire # Household From 45b71b207ef30e276f5f63b99a3bb886324642dd Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 16 Dec 2021 13:58:43 +0100 Subject: [PATCH 37/38] activity fix: display comment in list --- .../Resources/views/Activity/list.html.twig | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig index 8efdd0148..3f49e67cc 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/list.html.twig @@ -127,24 +127,25 @@
  • {% endif %} + {% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %} +
    +
    +

    {{ 'Comment'|trans }}

    +
    +
    + {{ activity.comment|chill_entity_render_box({ + 'disable_markdown': false, + 'limit_lines': 3, + 'metadata': false + }) }} +
    +
    + {% endif %} + {# Only if ACL SEE_DETAILS AND/OR only on template SHOW ?? durationTime travelTime comment - {% if activity.comment.comment is not empty and is_granted('CHILL_ACTIVITY_SEE_DETAILS', activity) %} -
    -
    -

    {{ 'Comment'|trans }}

    -
    -
    - {{ activity.comment|chill_entity_render_box({ - 'disable_markdown': false, - 'limit_lines': 3, - 'metadata': false - }) }} -
    -
    - {% endif %} documents attendee #} From 91bee4aad3b6f693967ef70351693cc723faaac7 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 16 Dec 2021 18:55:21 +0100 Subject: [PATCH 38/38] wip goal-result on resume page --- .../AccompanyingCourseWork/index.html.twig | 2 -- ...st_recent_by_accompanying_period.html.twig | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig index eb885d50a..cf91a4e20 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/index.html.twig @@ -155,7 +155,6 @@
    - {# SEULEMENT SI DÉTAILLÉ {% if w.results|length > 0 %}
    @@ -194,7 +193,6 @@
    {% endfor %} {% endif %} - #}
    diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig index b5fcb6c40..4bab107c5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourseWork/list_recent_by_accompanying_period.html.twig @@ -43,7 +43,39 @@
    - {% for e in w.accompanyingPeriodWorkEvaluations %} + A{% for g in w.goals %} +
  • + {{ 'accompanying_course_work.goal'|trans ~ ' : ' }} + {{ g.goal.title|localize_translatable_string }} + {% if g.results|length > 0 %} + {{ 'accompanying_course_work.results'|trans }} +
      + {% for r in g.results %} +
    • + {{ r.title|localize_translatable_string }} +
    • + {% endfor %} +
    + {% endif %} +
  • + {% endfor %} + B{% if w.results|length > 0 %} +
  • + {{ 'accompanying_course_work.goal'|trans }} +

    {{ 'accompanying_course_work.results without objective'|trans }}

    + {% if w.results %} + {{ 'accompanying_course_work.results'|trans }} +
      + {% for r in w.results %} +
    • + {{ r.title|localize_translatable_string }} +
    • + {% endfor %} +
    + {% endif %} +
  • + {% endif %} + C{% for e in w.accompanyingPeriodWorkEvaluations %}
  • {{ 'accompanying_course_work.social_evaluation'|trans ~ ' : ' }} {{ e.evaluation.title|localize_translatable_string }} @@ -55,7 +87,7 @@
  • {% endif %} {% if e.endDate %} -
  • +
  • {{ 'accompanying_course_work.end_date'|trans ~ ' : ' }} {{ e.endDate|format_date('short') }}