From e13b7bf195f0d4fa470b9df28cdf9d8ab4ccd835 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 20 Sep 2021 13:27:03 +0200 Subject: [PATCH] fix countrySelection multiselect with fetch async countries edit context: display country for existing address new context: repair editPane, load countries note: adding id for country and postcode in address endpoint json --- .../public/vuejs/Address/components/AddAddress.vue | 11 +++++++---- .../Serializer/Normalizer/AddressNormalizer.php | 2 ++ .../Resources/views/Address/new.html.twig | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index c0cb45c42..dd9171cc2 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -381,10 +381,12 @@ export default { if (this.flag.suggestPane === true) { this.closeSuggestPane(); } - this.initForm(); - this.getCountries(); - this.flag.editPane = true; + if (this.flag.showPane === true) { + this.closeShowPane(); + } console.log('step2: open the Edit panel'); + this.initForm(); + this.getCountries(); // will open edit pane when resolve promise } }, closeEditPane() { @@ -456,10 +458,11 @@ export default { getCountries() { this.flag.loading = true; + console.log('## GO'); fetchCountries().then( countries => new Promise((resolve, reject) => { this.entity.loaded.countries = countries.results; - this.flag.showPane = false; + console.log('## COMPLETE !'); this.flag.editPane = true; this.flag.loading = false; resolve() diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index 44998043b..9e3b5c11b 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -17,8 +17,10 @@ class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface $data['text'] = $address->isNoAddress() ? '' : $address->getStreetNumber().', '.$address->getStreet(); $data['street'] = $address->getStreet(); $data['streetNumber'] = $address->getStreetNumber(); + $data['postcode']['id'] = $address->getPostCode()->getId(); $data['postcode']['name'] = $address->getPostCode()->getName(); $data['postcode']['code'] = $address->getPostCode()->getCode(); + $data['country']['id'] = $address->getPostCode()->getCountry()->getId(); $data['country']['name'] = $address->getPostCode()->getCountry()->getName(); $data['country']['code'] = $address->getPostCode()->getCountry()->getCountryCode(); $data['floor'] = $address->getFloor(); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig index a3149ef38..14ddace0a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig @@ -30,10 +30,10 @@ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with { targetEntity: { name: 'person', id: person.id }, backUrl: path('chill_person_address_list', { 'person_id': person.id }), - openPanesInModal: false, stickyActions: true, } %} {# + openPanesInModal: false, useValidFrom: true, #}