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 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
|
||||
};
|
||||
|
@ -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">
|
||||
</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">
|
||||
<ul class="list-suggest add-items inline">
|
||||
<li v-for="(u, i) in referrersSuggested" @click="updateReferrer(u)" :key="`referrer-${i}`">
|
||||
@ -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)
|
||||
|
@ -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.",
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user