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 68bbe2afc..cd57ba3cd 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss
+++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/render_box.scss
@@ -94,8 +94,8 @@ section.chill-entity {
}
span.address-valid {
- &.address-since {}
- &.address-until {}
+ &.date-since {}
+ &.date-until {}
}
}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue
index a820c253d..c6a2ed8c8 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/App.vue
@@ -1,10 +1,28 @@
+ {{ addAddress.result.street }}
+ {{ addAddress.result.streetNumber }}
+
+ {{ addAddress.result.postcode.code }}
+ {{ addAddress.result.postcode.name }}
+ {{ addAddress.result.country.name.fr }}{{ $t(getTextTitle) }}
+
@@ -36,7 +39,7 @@
{{ $t('action.edit')}}
@@ -51,18 +54,20 @@
v-bind:default="this.default"
v-bind:entity="this.entity"
v-bind:flag="this.flag"
+ ref="showAddress"
v-bind:insideModal="false" @openEditPane="openEditPane"
- @submitAddress="$emit('submitAddress', { getSubmited , flag })">
+ @submitAddress="submitAddress">
+
{{ getTextTitle }}
Loading...
@@ -26,7 +28,8 @@
v-bind:options="this.options"
v-bind:default="this.default"
v-bind:entity="this.entity"
- v-bind:flag="this.flag">
+ v-bind:flag="this.flag"
+ ref="showAddress">
{{ $t(getTextTitle) }}
+
{{ getTextTitle }}
Loading...
@@ -122,8 +127,7 @@ import {
export default {
name: "AddAddress",
- props: ['context', 'options'],
- emits: ['submitAddress'],
+ props: ['context', 'options', 'result'],
components: {
Modal,
ShowAddress,
@@ -138,7 +142,11 @@ export default {
success: false
},
default: {
- textButton: { create: 'add_an_address_title', edit: 'edit_address' },
+ button: {
+ text: { create: 'add_an_address_title', edit: 'edit_address' },
+ type: 'btn-create',
+ display: true
+ },
title: { create: 'add_an_address_title', edit: 'edit_address' },
bindModal: {
step1: true,
@@ -173,34 +181,48 @@ export default {
zoom: 12
},
},
+ valid: {
+ from: null,
+ to: null
+ },
errorMsg: []
}
},
computed: {
-
- // TODO improve: props options must override data default
step1WithModal() {
- return (this.options.bindModal) ? this.options.bindModal.step1 : this.default.bindModal.step1;
+ return (this.options.bindModal !== null && typeof this.options.bindModal.step1 !== 'undefined') ?
+ this.options.bindModal.step1 : this.default.bindModal.step1;
},
step2WithModal() {
- return (this.options.bindModal) ? this.options.bindModal.step2 : this.default.bindModal.step2;
- },
+ let step2 = (this.options.bindModal !== null && typeof this.options.bindModal.step2 !== 'undefined') ?
+ this.options.bindModal.step2 : this.default.bindModal.step2;
- getTextButton() {
- if (this.options.textButton) {
- return (this.context.edit) ? this.options.textButton.edit : this.options.textButton.create;
+ if (step2 === false && this.step1WithModal === true) {
+ console.log("step2 must open in a Modal");
+ return true;
}
- return (this.context.edit) ? this.default.textButton.edit : this.default.textButton.create;
+ return step2;
},
getTextTitle() {
- if (this.options.title) {
+ if (this.options.title && (this.options.title.edit !== null || this.options.title.create !== null)) {
return (this.context.edit) ? this.options.title.edit : this.options.title.create;
}
- return (this.context.edit) ? this.default.title.edit : this.default.title.create;
+ return (this.context.edit) ? this.$t(this.default.title.edit) : this.$t(this.default.title.create);
},
-
- getSubmited() {
- return this.entity.address;
+ getTextButton() {
+ if (this.options.button && this.options.button.text && (this.options.button.text.edit !== null || this.options.button.text.create !== null)) {
+ return (this.context.edit) ? this.options.button.text.edit : this.options.button.text.create;
+ }
+ return (this.context.edit) ? this.default.button.text.edit : this.default.button.text.create;
+ },
+ getClassButton() {
+ let size = (this.options.button && this.options.button.size !== null) ? this.options.button.size : '';
+ let type = (this.options.button && this.options.button.type !== null) ? this.options.button.type : this.default.button.type;
+ return size ? size + ' ' + type : type;
+ },
+ displayTextButton() {
+ return (this.options.button !== null && typeof this.options.button.display !== 'undefined') ?
+ this.options.button.display : this.default.button.display;
}
},
mounted() {
@@ -219,13 +241,24 @@ export default {
if (this.context.addressId) {
this.getInitialAddress(this.context.addressId);
}
- this.flag.showPane = true;
+ // when create new address, start first with editPane
+ if ( this.context.edit === false
+ && this.flag.editPane === false
+ ) {
+ this.openEditPane();
+ this.flag.editPane = true;
+
+ } else {
+ this.flag.showPane = true;
+ }
},
+
openEditPane() {
console.log('open the Edit panel');
this.initForm();
this.getCountries();
},
+
closeEditPane() {
console.log('close the Edit Panel (with validation)');
this.applyChanges();
@@ -373,7 +406,6 @@ export default {
* then update existing address with backend datas when promise is resolved
*/
updateAddress(payload) {
- console.log('updateAddress payload', payload);
// TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode
this.flag.loading = true;
@@ -387,7 +419,6 @@ export default {
body.postcode = {'id': postalCode.id },
patchAddress(payload.addressId, body)
.then(address => new Promise((resolve, reject) => {
- console.log('update address');
this.entity.address = address;
this.flag.loading = false;
resolve();
@@ -401,7 +432,6 @@ export default {
} else {
patchAddress(payload.addressId, payload.newAddress)
.then(address => new Promise((resolve, reject) => {
- console.log('update address');
this.entity.address = address;
this.flag.loading = false;
resolve();
@@ -418,7 +448,6 @@ export default {
* creating new address, and receive backend datas when promise is resolved
*/
addAddress(payload) {
- console.log('addAddress payload', payload);
this.flag.loading = true;
if('newPostcode' in payload){
@@ -431,7 +460,6 @@ export default {
body.postcode = {'id': postalCode.id},
postAddress(body)
.then(address => new Promise((resolve, reject) => {
- console.log('add address');
this.entity.address = address;
resolve();
this.flag.loading = false;
@@ -445,7 +473,6 @@ export default {
} else {
postAddress(payload)
.then(address => new Promise((resolve, reject) => {
- console.log('add address');
this.entity.address = address;
resolve();
this.flag.loading = false;
@@ -455,9 +482,55 @@ export default {
this.flag.loading = false;
});
}
+ },
+
+ /*
+ * When submited
+ */
+ submitAddress() {
+ console.log('@@@ CLICK button submitAddress');
+ this.addDateToAddressAndAddressToPerson({
+ personId: this.context.personId,
+ addressId: this.entity.address.address_id,
+ body: { validFrom: { datetime: `${this.$refs.showAddress.validFrom}T00:00:00+0100`}},
+ backUrl: this.context.backUrl
+ });
+ this.initForm();
+ this.flag.showPane = false;
+ },
+
+ addDateToAddressAndAddressToPerson(payload) {
+ console.log('addDateToAddressAndAddressToPerson payload', payload);
+ this.flag.loading = true;
+ patchAddress(payload.addressId, payload.body)
+ .then(address => new Promise((resolve, reject) => {
+ this.valid.from = address.validFrom;
+ resolve();
+ }).then(
+ postAddressToPerson(payload.personId, payload.addressId)
+ .then(person => new Promise((resolve, reject) => {
+
+ console.log('commit addAddressToPerson !!!', person);
+ this.$props.result = person;
+
+ this.flag.loading = false;
+ this.flag.success = true;
+
+ if (this.options.redirectToBackUrl) {
+ window.location.assign(payload.backUrl);
+ }
+ resolve();
+ }))
+ .catch((error) => {
+ this.errorMsg.push(error);
+ this.flag.loading = false;
+ })
+ ))
+ .catch((error) => {
+ this.errorMsg.push(error);
+ this.flag.loading = false;
+ });
}
-
-
}
}
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowAddress.vue
index c59104aca..07e4617d3 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowAddress.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowAddress.vue
@@ -20,41 +20,63 @@
{{ address.country.name.fr }}