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 3b5aea2bb..e29f85bc7 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue
@@ -27,10 +27,12 @@
-
@@ -52,8 +54,8 @@ export default {
data() {
return {
addAddress: {
+ type: 'accompanying_course_location',
options: {
-
/// Options override default.
/// null value take default component value
button: {
@@ -69,13 +71,8 @@ export default {
/// Display each step in page or Modal
bindModal: {
//step1: false, step2: false
- },
- // Options only for root parent component
- displayResult: true,
- redirectToBackUrl: false
- },
- type: 'accompanying_course_location',
- result: null // <== returned from addAddress component
+ }
+ }
}
}
},
@@ -83,27 +80,43 @@ export default {
...mapState({
accompanyingCourse: state => state.accompanyingCourse,
context: state => state.addressContext
- })
+ }),
+ hasTemporaryAddressButton() { // return true if locationStatus equal 'none' or 'address'
+ return this.accompanyingCourse.locationStatus !== 'person';
+ }
},
methods: {
initAddressContext() {
- let ac = {
+ let context = {
entity: {
type: this.accompanyingCourse.type,
id: this.accompanyingCourse.id
},
edit: false,
- addressId: null,
- backUrl: null
+ addressId: null
}
- this.$store.commit('setAddressContext', ac);
+ if (this.accompanyingCourse.location) {
+ context['edit'] = true;
+ context['addressId'] = this.accompanyingCourse.location.address_id
+ }
+ this.$store.commit('setAddressContext', context);
},
displayErrors() {
return this.$refs.addAddress.errorMsg;
+ },
+ submitAddress() {
+ console.log('@@@ click on Submit Address Button');
+
+ let payload = this.$refs.addAddress.submitNewAddress();
+ console.log('payload from parent', payload);
+
+ this.$store.dispatch('updateLocation', payload);
+
}
},
mounted() {
this.initAddressContext();
+
console.log('ac.locationStatus', this.accompanyingCourse.locationStatus);
console.log('ac.location (temporary location)', this.accompanyingCourse.location);
console.log('ac.personLocation', this.accompanyingCourse.personLocation);
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 68c23966c..83f90fb91 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
@@ -1,4 +1,5 @@
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
+import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n';
const appMessages = {
fr: {
@@ -100,7 +101,7 @@ const appMessages = {
}
};
-Object.assign(appMessages.fr, personMessages.fr);
+Object.assign(appMessages.fr, personMessages.fr, addressMessages.fr);
export {
appMessages
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
index b62967616..7fbdd67e6 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
@@ -1,5 +1,6 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
+import { patchAddressToAccompanyingPeriod } from "../../_api/AddAddress.js";
import { getAccompanyingCourse,
patchAccompanyingCourse,
confirmAccompanyingCourse,
@@ -8,6 +9,7 @@ import { getAccompanyingCourse,
postResource,
postSocialIssue } from '../api';
+
const debug = process.env.NODE_ENV !== 'production';
const id = window.accompanyingCourseId;
@@ -97,6 +99,12 @@ let initPromise = getAccompanyingCourse(id)
setAddressContext(state, context) {
//console.log('define location context');
state.addressContext = context;
+ },
+ updateLocation(state, r) {
+ console.log('### mutation: set location attributes', r);
+ state.accompanyingCourse.location = r.location;
+ state.accompanyingCourse.locationStatus = r.locationStatus;
+ state.accompanyingCourse.personLocation = r.personLocation;
}
},
actions: {
@@ -214,6 +222,20 @@ let initPromise = getAccompanyingCourse(id)
resolve();
})).catch((error) => { commit('catchError', error) });
},
+ /////
+ updateLocation({ commit }, payload) {
+ console.log('## action: updateLocation', payload);
+ patchAddressToAccompanyingPeriod(payload.entityId, payload.addressId)
+ .then(accompanyingCourse => new Promise((resolve, reject) => {
+ commit('updateLocation', {
+ location: accompanyingCourse.location,
+ locationStatus: accompanyingCourse.locationStatus,
+ personLocation: accompanyingCourse.personLocation
+ });
+ resolve();
+ })).catch((error) => { commit('catchError', error) });
+ },
+ /////
confirmAccompanyingCourse({ commit }) {
//console.log('## action: confirmAccompanyingCourse');
confirmAccompanyingCourse(id)
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
index 749750b67..8f250fc04 100644
--- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
+++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig
@@ -205,8 +205,7 @@ This view should receive those arguments:
mode: 'edit',
address_id: person.lastAddress.id,
backUrl: path('chill_person_view', { 'person_id': person.id }),
- modalTitle: 'Edit address',
- buttonText: 'Edit address',
+ modalTitle: 'Edit address', buttonText: 'Edit address',
buttonType: 'btn-update',
buttonSize: 'btn-sm',
buttonDisplay: false