diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss index 31d2c8d09..6100bc842 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss @@ -98,6 +98,9 @@ section.chill-entity { &.date-since {} &.date-until {} } + .address-more { + margin-bottom: 1em; + } } // used for comment-embeddable 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 a37cd4ee3..80668270f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -7,6 +7,7 @@ v-bind:defaultz="this.defaultz" v-bind:entity="this.entity" v-bind:flag="this.flag" + v-bind:useDatePane="this.useDatePane" @openEditPane="openEditPane" ref="showAddress"> @@ -101,10 +102,8 @@ @@ -197,10 +196,16 @@ v-bind:insideModal="false" ref="dateAddress"> + @@ -276,7 +281,7 @@ export default { }, valid: { from: new Date(), - to: new Date() + to: null } }, addressMap: { @@ -330,11 +335,6 @@ export default { }, mounted() { - //console.log('options displayText', this.options.button.displayText); - //console.log('options bindModal.step1', this.options.bindModal.step1); - //console.log('options bindModal.step2', this.options.bindModal.step2); - //console.log('options useDate.validFrom', this.options.useDate.validFrom); - //console.log('options useDate.validTo', this.options.useDate.validTo); console.log('useDatePane', this.useDatePane); console.log('Mounted now !'); @@ -380,7 +380,9 @@ export default { console.log('displaySuggestions'); this.openSuggestPane(); } else { - this.initForm(); + if (this.flag.datePane === false) { + this.initForm(); // reset form except if we come back from datePane + } this.getCountries(); // will open editPane when resolve promise } }, @@ -456,11 +458,14 @@ export default { fetchCountries().then( countries => new Promise((resolve, reject) => { this.entity.loaded.countries = countries.results; + if (this.flag.showPane === true) { + this.closeShowPane(); + } if (this.flag.suggestPane === true) { this.closeSuggestPane(); } - if (this.flag.showPane === true) { - this.closeShowPane(); + if (this.flag.datePane === true) { + this.flag.datePane = false; } console.log('step2: open the Edit panel'); this.flag.editPane = true; @@ -600,8 +605,10 @@ export default { if (this.context.target.name === 'person') { // !!! maintain here ? postcodeBody = Object.assign(postcodeBody, {'origin': 3}); } + console.log('juste before post new postcode', postcodeBody); return postPostalCode(postcodeBody) .then(postalCode => { + console.log('new postcode created', postalCode.id); payload.postcode = {'id': postalCode.id }; return this.postNewAddress(payload); }); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue index 87cb65549..69e4ccea6 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/DatePane.vue @@ -9,29 +9,31 @@ {{ errorMsg }} - + -
-

{{ $t(getValidFromDateText) }}

-
- - +
+
+

{{ $t(getValidFromDateText) }}

+
+ + +
-
-
-

{{ $t(getValidToDateText) }}

-
- - +
+

{{ $t(getValidToDateText) }}

+
+ + +
@@ -88,7 +90,7 @@ export default { this.entity.selected.valid.to = ISOToDate(value); }, get() { - return dateToISO(this.entity.selected.valid.from); + return dateToISO(this.entity.selected.valid.to); } }, getValidFromDateText() { @@ -102,6 +104,35 @@ export default { }, showDateTo() { return !this.context.edit && this.options.useDate.validTo; + }, + selectedAddress() { + let address = {}; + + address['country'] = (this.entity.selected.country) ? this.entity.selected.country : null; + address['postcode'] = (this.entity.selected.postcode) ? this.entity.selected.postcode : null; + + if (this.entity.selected.address) { + let number = (this.entity.selected.address.streetNumber) ? this.entity.selected.address.streetNumber : null; + let street = (this.entity.selected.address.street) ? this.entity.selected.address.street : null; + address['text'] = number + ', ' + street; + + address['street'] = (this.entity.selected.address.street) ? this.entity.selected.address.street : null; + address['streetNumber'] = (this.entity.selected.address.streetNumber) ? this.entity.selected.address.streetNumber : null; + address['floor'] = (this.entity.selected.address.floor) ? this.entity.selected.address.floor : null; + address['corridor'] = (this.entity.selected.address.corridor) ? this.entity.selected.address.corridor : null; + address['steps'] = (this.entity.selected.address.steps) ? this.entity.selected.address.steps : null; + address['flat'] = (this.entity.selected.address.flat) ? this.entity.selected.address.flat : null; + address['buildingName'] = (this.entity.selected.address.buildingName) ? this.entity.selected.address.buildingName : null; + address['distribution'] = (this.entity.selected.address.distribution) ? this.entity.selected.address.distribution : null; + address['extra'] = (this.entity.selected.address.extra) ? this.entity.selected.address.extra : null; + } + + if (this.entity.selected.valid) { + address['validFrom'] = (this.entity.selected.valid.from) ? dateToISO(this.entity.selected.valid.from) : null; + address['validTo'] = (this.entity.selected.valid.to) ? dateToISO(this.entity.selected.valid.to) : null; + } + + return address; } } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue index 405ba0cc7..a4e5c571d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue @@ -21,7 +21,7 @@

- +
+
+
+ + {{ $t('validFrom') }}: {{ $d(address.validFrom.date) }} + +
+
+ + {{ $t('validTo') }}: {{ $d(address.validTo.date) }} + +
+
+ @@ -67,6 +80,10 @@ export default { isMultiline: { default: true, type: Boolean + }, + useDatePane: { + default: false, + type: Boolean } }, computed: { diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index 9e3b5c11b..2b39c07c3 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -13,6 +13,7 @@ class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface public function normalize($address, string $format = null, array $context = []) { + /** @var Address $address */ $data['address_id'] = $address->getId(); $data['text'] = $address->isNoAddress() ? '' : $address->getStreetNumber().', '.$address->getStreet(); $data['street'] = $address->getStreet(); @@ -30,6 +31,8 @@ class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface $data['buildingName'] = $address->getBuildingName(); $data['distribution'] = $address->getDistribution(); $data['extra'] = $address->getExtra(); + $data['validFrom'] = $address->getValidFrom(); + $data['validTo'] = $address->getValidTo(); return $data; } 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 bb300a545..83bc1126f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -89,9 +89,9 @@ export default { /// Display each step in page or Modal openPanesInModal: true, // Use Date fields - useDate: { - validFrom: true - }, + //useDate: { + // validFrom: true + //}, hideAddress: true } } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig index da2bfe474..c88959340 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Address/new.html.twig @@ -30,11 +30,12 @@ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with { targetEntity: { name: 'person', id: person.id }, stickyActions: true, + useValidFrom: true, } %} {# + useValidTo: true, backUrl: path('chill_person_address_list', { 'person_id': person.id }), openPanesInModal: false, - useValidFrom: true, #} {% endblock %}