From 3ca46efd2c92d9a8ae8be508fcde1862d6a1578b Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 17 Nov 2022 16:12:30 +0100 Subject: [PATCH] #16 pass default variables to add-address component when it is called from another vue component --- .../public/vuejs/Activity/components/Location/NewLocation.vue | 3 ++- .../Resources/views/Activity/editAccompanyingCourse.html.twig | 1 + .../Resources/views/Activity/editPerson.html.twig | 1 + .../Resources/views/Activity/newAccompanyingCourse.html.twig | 1 + .../Resources/views/Activity/newPerson.html.twig | 1 + src/Bundle/ChillMainBundle/Resources/views/layout.html.twig | 1 + .../vuejs/AccompanyingCourse/components/CourseLocation.vue | 3 ++- .../public/vuejs/HouseholdMembersEditor/store/index.js | 3 +++ .../Resources/public/vuejs/_components/OnTheFly/Person.vue | 3 ++- .../Resources/views/AccompanyingCourse/edit.html.twig | 1 + .../Resources/views/Household/members_editor.html.twig | 1 + .../Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue | 3 ++- 12 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue index 6a6289875..568c8747a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue @@ -117,7 +117,8 @@ export default { target: { //name, id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig index d0359e223..a07fde4aa 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editAccompanyingCourse.html.twig @@ -22,6 +22,7 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; + window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig index 91b3867c1..efb511bab 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/editPerson.html.twig @@ -37,6 +37,7 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; + window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig index 47a61bd86..05a92fb5a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newAccompanyingCourse.html.twig @@ -18,6 +18,7 @@ {{ encore_entry_script_tags('mod_async_upload') }} {{ encore_entry_script_tags('vue_activity') }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig index d57fc3412..f1a13b61f 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/newPerson.html.twig @@ -21,6 +21,7 @@ '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}'); }); window.activity = {{ activity_json|json_encode|raw }}; + window.addaddress = {{ add_address|json_encode|raw }}; {{ encore_entry_script_tags('vue_activity') }} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 5543809fc..cafe8dd0d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -109,6 +109,7 @@ }); chill.categoryLinkParentChildSelect(); }); + window.addaddress = {{ add_address|json_encode|raw }}; {% block js %}{% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index 42f974dd1..99e3519f4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -164,7 +164,8 @@ export default { id: this.accompanyingCourse.id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } if (this.accompanyingCourse.location) { context['edit'] = true; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index f3801576d..bbdde0dfa 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -5,6 +5,7 @@ import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/househol import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js'; const debug = process.env.NODE_ENV !== 'production'; +//console.log('AJAJAJA', window.addaddress); const concerned = window.household_members_editor_data.persons.map(p => { return { @@ -115,6 +116,7 @@ const store = createStore({ name: state.household.type, id: state.household.id }, + defaults: window.addaddress, suggestions: state.addressesSuggestion }; } else { @@ -125,6 +127,7 @@ const store = createStore({ name: state.household.type, id: state.household.id }, + defaults: window.addaddress, }; } }, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 4f8909233..646d92b35 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -201,7 +201,8 @@ export default { context: { target: {}, // boilerplate for getting the address id edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } }, errors: [] diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig index b3520349b..4197f6418 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/edit.html.twig @@ -10,6 +10,7 @@ {{ encore_entry_script_tags('vue_accourse') }} {% endblock %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig index 8b0134f6b..12d1ddf57 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/members_editor.html.twig @@ -19,6 +19,7 @@ {{ encore_entry_script_tags('vue_household_members_editor') }} {% endblock %} 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 0ea011dc4..765d67fe8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -232,7 +232,8 @@ export default { id: this.id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress }; if ( !(this.thirdparty.address === undefined || this.thirdparty.address === null) && this.thirdparty.address.address_id !== null