mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
accompanying course: add selector for accompanying course job
This commit is contained in:
parent
175fa7bf2f
commit
16c86daafb
@ -15,21 +15,15 @@ const getAccompanyingCourse = (id) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUsers = () => {
|
const getUsers = () => fetchResults('/api/1.0/main/user.json');
|
||||||
const url = `/api/1.0/main/user.json`;
|
|
||||||
|
|
||||||
return fetchResults(url);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getReferrersSuggested = (course) => {
|
const getReferrersSuggested = (course) => {
|
||||||
const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`;
|
const url = `/api/1.0/person/accompanying-course/${course.id}/referrers-suggested.json`;
|
||||||
|
|
||||||
return fetchResults(url);
|
return fetchResults(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
const getUserJobs = () => fetchResults('/api/1.0/main/user-job.json');
|
||||||
* Endpoint
|
|
||||||
*/
|
|
||||||
const getSocialIssues = () => {
|
const getSocialIssues = () => {
|
||||||
const url = `/api/1.0/person/social-work/social-issue.json`;
|
const url = `/api/1.0/person/social-work/social-issue.json`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
@ -54,4 +48,5 @@ export {
|
|||||||
getAccompanyingCourse,
|
getAccompanyingCourse,
|
||||||
getUsers,
|
getUsers,
|
||||||
getReferrersSuggested,
|
getReferrersSuggested,
|
||||||
|
getUserJobs
|
||||||
};
|
};
|
||||||
|
@ -15,13 +15,33 @@
|
|||||||
:searchable="true"
|
:searchable="true"
|
||||||
:placeholder="$t('referrer.placeholder')"
|
:placeholder="$t('referrer.placeholder')"
|
||||||
v-model="value"
|
v-model="value"
|
||||||
v-bind:options="users"
|
:options="users"
|
||||||
:select-label="$t('multiselect.select_label')"
|
:select-label="$t('multiselect.select_label')"
|
||||||
:deselect-label="$t('multiselect.deselect_label')"
|
:deselect-label="$t('multiselect.deselect_label')"
|
||||||
:selected-label="$t('multiselect.selected_label')"
|
:selected-label="$t('multiselect.selected_label')"
|
||||||
@select="updateReferrer">
|
@select="updateReferrer">
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
|
|
||||||
|
<label class="col-form-label" for="selectJob">
|
||||||
|
{{ $t('job.label') }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<VueMultiselect
|
||||||
|
name="selectJob"
|
||||||
|
label="text"
|
||||||
|
:custom-label="customJobLabel"
|
||||||
|
track-by="id"
|
||||||
|
:multiple="false"
|
||||||
|
:searchable="true"
|
||||||
|
:placeholder="$t('job.placeholder')"
|
||||||
|
v-model="valueJob"
|
||||||
|
:options="jobs"
|
||||||
|
:select-label="$t('multiselect.select_label')"
|
||||||
|
:deselect-label="$t('multiselect.deselect_label')"
|
||||||
|
:selected-label="$t('multiselect.selected_label')"
|
||||||
|
@select="updateJob">
|
||||||
|
</VueMultiselect>
|
||||||
|
|
||||||
<template v-if="referrersSuggested.length > 0">
|
<template v-if="referrersSuggested.length > 0">
|
||||||
<ul class="list-suggest add-items inline">
|
<ul class="list-suggest add-items inline">
|
||||||
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
|
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
|
||||||
@ -62,9 +82,15 @@ export default {
|
|||||||
UserRenderBoxBadge,
|
UserRenderBoxBadge,
|
||||||
VueMultiselect,
|
VueMultiselect,
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
jobs: []
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
value: state => state.accompanyingCourse.user,
|
value: state => state.accompanyingCourse.user,
|
||||||
|
valueJob: state => state.accompanyingCourse.job,
|
||||||
users: state => state.users,
|
users: state => state.users,
|
||||||
referrersSuggested: state => {
|
referrersSuggested: state => {
|
||||||
return state.referrersSuggested.filter(u => {
|
return state.referrersSuggested.filter(u => {
|
||||||
@ -76,6 +102,11 @@ export default {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getJobs();
|
||||||
|
console.log(this.users)
|
||||||
|
console.log(this.jobs)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateReferrer(value) {
|
updateReferrer(value) {
|
||||||
//console.log('value', 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() {
|
assignMe() {
|
||||||
const url = `/api/1.0/main/whoami.json`;
|
const url = `/api/1.0/main/whoami.json`;
|
||||||
makeFetch('GET', url)
|
makeFetch('GET', url)
|
||||||
|
@ -140,6 +140,10 @@ const appMessages = {
|
|||||||
ok: "Confirmer le parcours",
|
ok: "Confirmer le parcours",
|
||||||
delete: "Supprimer le parcours"
|
delete: "Supprimer le parcours"
|
||||||
},
|
},
|
||||||
|
job: {
|
||||||
|
label: "Métier",
|
||||||
|
placeholder: "Choisir un métier"
|
||||||
|
},
|
||||||
// catch errors
|
// catch errors
|
||||||
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",
|
'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.",
|
'Error while retriving AccompanyingPeriod Course.': "Erreur du serveur lors du chargement du parcours d'accompagnement.",
|
||||||
|
@ -193,6 +193,9 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
//console.log('value', value);
|
//console.log('value', value);
|
||||||
state.accompanyingCourse.user = value;
|
state.accompanyingCourse.user = value;
|
||||||
},
|
},
|
||||||
|
updateJob(state, value) {
|
||||||
|
state.accompanyingCourse.job = value;
|
||||||
|
},
|
||||||
setReferrersSuggested(state, users) {
|
setReferrersSuggested(state, users) {
|
||||||
state.referrersSuggested = users.map(u => {
|
state.referrersSuggested = users.map(u => {
|
||||||
if (state.accompanyingCourse.user !== null) {
|
if (state.accompanyingCourse.user !== null) {
|
||||||
@ -624,8 +627,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateOrigin({ commit }, payload) {
|
updateOrigin({ commit }, payload) {
|
||||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||||
const body = { type: "accompanying_period", origin: { id: payload.id, type: payload.type }}
|
const body = { type: "accompanying_period", origin: { id: payload.id, type: payload.type }};
|
||||||
|
|
||||||
return makeFetch('PATCH', url, body)
|
return makeFetch('PATCH', url, body)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -637,8 +640,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateAdminLocation({ commit }, payload) {
|
updateAdminLocation({ commit }, payload) {
|
||||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||||
const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }}
|
const body = { type: "accompanying_period", administrativeLocation: { id: payload.id, type: payload.type }};
|
||||||
|
|
||||||
return makeFetch('PATCH', url, body)
|
return makeFetch('PATCH', url, body)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -650,8 +653,8 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateReferrer({ commit }, payload) {
|
updateReferrer({ commit }, payload) {
|
||||||
const url = `/api/1.0/person/accompanying-course/${id}.json`
|
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||||
const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }}
|
const body = { type: "accompanying_period", user: { id: payload.id, type: payload.type }};
|
||||||
|
|
||||||
return makeFetch('PATCH', url, body)
|
return makeFetch('PATCH', url, body)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@ -662,6 +665,19 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
throw error;
|
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}) {
|
async fetchReferrersSuggested({ state, commit}) {
|
||||||
let users = await getReferrersSuggested(state.accompanyingCourse);
|
let users = await getReferrersSuggested(state.accompanyingCourse);
|
||||||
commit('setReferrersSuggested', users);
|
commit('setReferrersSuggested', users);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user