diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
index 8e4134205..ab95229a2 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js
@@ -15,21 +15,15 @@ const getAccompanyingCourse = (id) => {
});
};
-const getUsers = () => {
- const url = `/api/1.0/main/user.json`;
-
- return fetchResults(url);
-};
+const getUsers = () => fetchResults('/api/1.0/main/user.json');
const getReferrersSuggested = (course) => {
const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`;
-
return fetchResults(url);
}
-/*
-* Endpoint
-*/
+const getUserJobs = () => fetchResults('/api/1.0/main/user-job.json');
+
const getSocialIssues = () => {
const url = `/api/1.0/person/social-work/social-issue.json`;
return fetch(url)
@@ -54,4 +48,5 @@ export {
getAccompanyingCourse,
getUsers,
getReferrersSuggested,
+ getUserJobs
};
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue
index 0556e342a..f801ca355 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Referrer.vue
@@ -15,13 +15,33 @@
:searchable="true"
:placeholder="$t('referrer.placeholder')"
v-model="value"
- v-bind:options="users"
+ :options="users"
:select-label="$t('multiselect.select_label')"
:deselect-label="$t('multiselect.deselect_label')"
:selected-label="$t('multiselect.selected_label')"
@select="updateReferrer">
+
+
+
+
+
-
@@ -62,9 +82,15 @@ export default {
UserRenderBoxBadge,
VueMultiselect,
},
+ data() {
+ return {
+ jobs: []
+ }
+ },
computed: {
...mapState({
value: state => state.accompanyingCourse.user,
+ valueJob: state => state.accompanyingCourse.job,
users: state => state.users,
referrersSuggested: state => {
return state.referrersSuggested.filter(u => {
@@ -76,6 +102,11 @@ export default {
},
}),
},
+ mounted() {
+ this.getJobs();
+ console.log(this.users)
+ console.log(this.jobs)
+ },
methods: {
updateReferrer(value) {
//console.log('value', value);
@@ -88,6 +119,30 @@ export default {
}
});
},
+ getJobs() {
+ const url = '/api/1.0/main/user-job.json';
+ makeFetch('GET', url)
+ .then(response => {
+ this.jobs = response.results;
+ })
+ .catch((error) => {
+ this.$toast.open({message: error.txt})
+ })
+ },
+ updateJob(value) {
+ console.log(value)
+ this.$store.dispatch('updateJob', value)
+ .catch(({name, violations}) => {
+ if (name === 'ValidationException' || name === 'AccessException') {
+ violations.forEach((violation) => this.$toast.open({message: violation}));
+ } else {
+ this.$toast.open({message: 'An error occurred'})
+ }
+ });
+ },
+ customJobLabel(value) {
+ return value.label.fr;
+ },
assignMe() {
const url = `/api/1.0/main/whoami.json`;
makeFetch('GET', url)
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 04bbef9ef..223a4526e 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js
@@ -140,6 +140,10 @@ const appMessages = {
ok: "Confirmer le parcours",
delete: "Supprimer le parcours"
},
+ job: {
+ label: "Métier",
+ placeholder: "Choisir un métier"
+ },
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",
'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.",
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 43400d8eb..6767de6f8 100644
--- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
+++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js
@@ -193,6 +193,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
//console.log('value', value);
state.accompanyingCourse.user = value;
},
+ updateJob(state, value) {
+ state.accompanyingCourse.job = value;
+ },
setReferrersSuggested(state, users) {
state.referrersSuggested = users.map(u => {
if (state.accompanyingCourse.user !== null) {
@@ -624,8 +627,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
})
},
updateOrigin({ commit }, payload) {
- const url = `/api/1.0/person/accompanying-course/${id}.json`
- const body = { type: "accompanying_period", origin: { id: payload.id, type: payload.type }}
+ const url = `/api/1.0/person/accompanying-course/${id}.json`;
+ const body = { type: "accompanying_period", origin: { id: payload.id, type: payload.type }};
return makeFetch('PATCH', url, body)
.then((response) => {
@@ -637,8 +640,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
})
},
updateAdminLocation({ commit }, payload) {
- const url = `/api/1.0/person/accompanying-course/${id}.json`
- const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }}
+ const url = `/api/1.0/person/accompanying-course/${id}.json`;
+ const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }};
return makeFetch('PATCH', url, body)
.then((response) => {
@@ -650,8 +653,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
})
},
updateReferrer({ commit }, payload) {
- const url = `/api/1.0/person/accompanying-course/${id}.json`
- const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }}
+ const url = `/api/1.0/person/accompanying-course/${id}.json`;
+ const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }};
return makeFetch('PATCH', url, body)
.then((response) => {
@@ -662,6 +665,19 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
throw error;
})
},
+ updateJob({ commit }, payload) {
+ const url = `/api/1.0/person/accompanying-course/${id}.json`;
+ const body = { type: "accompanying_period", job: { id: payload.id, type: payload.type }};
+
+ return makeFetch('PATCH', url, body)
+ .then((response) => {
+ commit('updateJob', response.user);
+ })
+ .catch((error) => {
+ commit('catchError', error);
+ throw error;
+ })
+ },
async fetchReferrersSuggested({ state, commit}) {
let users = await getReferrersSuggested(state.accompanyingCourse);
commit('setReferrersSuggested', users);