diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/api.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/api.js
new file mode 100644
index 000000000..6ab71a429
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/api.js
@@ -0,0 +1,14 @@
+/*
+* Endpoint chill_main_address_reference_api_show
+* method GET, get AddressReference Object
+* @returns {Promise} a promise containing all AddressReference object
+*
+*/
+export const getReferenceAddress = () => {
+ const url = `/api/1.0/main/address-reference.json`;
+ return fetch(url)
+ .then(response => {
+ if (response.ok) { return response.json(); }
+ throw Error('Error with request resource response');
+ });
+};
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js
index 8b31a2368..e58cd4483 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js
@@ -1,32 +1,22 @@
import { createApp } from 'vue'
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
-import { appMessages } from './js/i18n'
+import { addressMessages } from './js/i18n'
import { getDataPromise } from './store'
import App from './App.vue';
-// getDataPromise.then(store => {
+getDataPromise.then(store => {
-// console.log('store address', store.state.address);
+ console.log('store address', store.state.referenceAddresses);
-// const i18n = _createI18n(appMessages);
-// console.log(i18n)
+ const i18n = _createI18n(addressMessages);
-// const app = createApp({
-// template: ``,
-// })
-// .use(store)
-// .use(i18n)
-// .component('app', App)
-// .mount('#address');
+ const app = createApp({
+ template: ``,
+ })
+ .use(store)
+ .use(i18n)
+ .component('app', App)
+ .mount('#address');
-// });
-
-const i18n = _createI18n(appMessages);
-
-const app = createApp({
- template: ``,
-})
-.use(i18n)
-.component('app', App)
-.mount('#address');
+});
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/js/i18n.js
index 0bfdfb380..268d6d2a0 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/js/i18n.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/js/i18n.js
@@ -1,15 +1,13 @@
// import { mainMessages } from 'ChillMainAssets/vuejs/_js/i18n'
-const appMessages = {
+const addressMessages = {
fr: {
- address: {
- id: "id",
- },
+ add_an_address: 'Ajouter une adresse'
}
};
// Object.assign(appMessages.fr, mainMessages.fr);
export {
- appMessages
+ addressMessages
};
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js
index e69de29bb..1c92719f6 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js
@@ -0,0 +1,115 @@
+import 'es6-promise/auto';
+import { createStore } from 'vuex';
+import { getReferenceAddress } from '../api';
+//import { searchPersons } from 'ChillPersonAssets/vuejs/_api/AddPersons'
+
+const debug = process.env.NODE_ENV !== 'production';
+
+// const id = window.accompanyingCourseId; //tmp TODO
+
+const getDataPromise = getReferenceAddress()
+ .then(referenceAddresses => new Promise((resolve, reject) => {
+
+ const store = createStore({
+ strict: debug,
+ state: {
+ referenceAddresses: referenceAddresses.results,
+ countries: ['france', 'belgium'] //TODO fetch countries from CHILL API
+ // add_persons: {
+ // query: "",
+ // suggested: [],
+ // selected: []
+ // },
+ // errorMsg: []
+ },
+ getters: {
+ getCountries: state => state.countries,
+ getReferenceAddresses: state => state.referenceAddresses,
+ // getReferenceAddressesCities: state => {}, //TODO get unique cities from addressReference
+ },
+ mutations: {
+ // removeParticipation(state, item) {
+ // //console.log('mutation: remove item', item.id);
+ // state.accompanying_course.participations = state.accompanying_course.participations.filter(participation => participation !== item);
+ // },
+ // closeParticipation(state, { participation, payload }) {
+ // console.log('### mutation: close item', { participation, payload });
+ // // temporaire, le temps que le backend ajoute la enddate
+ // participation.endDate = { datetime: "2021-05-06T10:49:00+0200" };
+ // // trouve dans le state le payload et le supprime du state
+ // state.accompanying_course.participations = state.accompanying_course.participations.filter(participation => participation !== payload);
+ // // pousse la participation
+ // state.accompanying_course.participations.push(participation);
+ // },
+ // addParticipation(state, { participation, payload }) {
+ // //console.log('### mutation: add participation', participation);
+ // state.accompanying_course.participations.push(participation);
+ // //console.log('count participations from state', state.accompanying_course.participations.length);
+ // //console.log('avant', state.add_persons.selected);
+ // state.add_persons.selected = state.add_persons.selected.filter(value => value !== payload);
+ // //console.log('après', state.add_persons.selected);
+ // state.add_persons.query = "";
+ // state.add_persons.suggested = [];
+ // },
+ // setQuery(state, query) {
+ // //console.log('q=', query);
+ // state.add_persons = Object.assign({}, state.add_persons, query);
+ // },
+ // loadSuggestions(state, suggested) {
+ // state.add_persons.suggested = suggested;
+ // },
+ // updateSelected(state, value) {
+ // state.add_persons.selected = value;
+ // }
+ },
+ actions: {
+ // removeParticipation({ commit }, payload) {
+ // commit('removeParticipation', payload);
+ // },
+ // closeParticipation({ commit }, payload) {
+ // console.log('## action: fetch delete participation: payload', payload.person.id);
+ // postParticipation(id, payload.person.id, 'DELETE')
+ // .then(participation => new Promise((resolve, reject) => {
+ // //console.log('payload', payload);
+ // commit('closeParticipation', { participation, payload });
+ // resolve();
+ // }))
+ // .catch((error) => {
+ // console.log('error', error);
+ // state.errorMsg.push(error.message);
+ // });
+ // },
+ // addParticipation({ commit }, payload) {
+ // console.log('## action: fetch post participation: payload', payload.id);
+ // postParticipation(id, payload.id, 'POST')
+ // .then(participation => new Promise((resolve, reject) => {
+ // commit('addParticipation', { participation, payload });
+ // resolve();
+ // }))
+ // .catch((error) => {
+ // state.errorMsg.push(error.message);
+ // });
+ // },
+ // setQuery({ commit }, payload) {
+ // commit('setQuery', payload);
+ // //console.log('## action: setquery: payload', payload);
+ // if (payload.query.length >= 3) {
+ // searchPersons(payload.query)
+ // .then(suggested => new Promise((resolve, reject) => {
+ // commit('loadSuggestions', suggested.results);
+ // resolve();
+ // }));
+ // } else {
+ // commit('loadSuggestions', []);
+ // }
+ // },
+ // updateSelected({ commit }, payload) {
+ // //console.log('## action: update selected values: payload', payload);
+ // commit('updateSelected', payload);
+ // }
+ }
+ });
+ resolve(store);
+ }));
+
+export { getDataPromise };
diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue
index a3ade00e0..90f1adc9b 100644
--- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue
+++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue
@@ -1,7 +1,6 @@
@@ -10,13 +9,28 @@
@close="modal.showModal = false">
- mon titre
+ {{ $t('add_an_address') }}
+
+
-
@@ -53,13 +67,13 @@