mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
New component for parcours startDate
This commit is contained in:
parent
71ca912749
commit
ad4153a07e
@ -14,6 +14,7 @@
|
|||||||
<scopes></scopes>
|
<scopes></scopes>
|
||||||
<referrer></referrer>
|
<referrer></referrer>
|
||||||
<resources></resources>
|
<resources></resources>
|
||||||
|
<start-date v-if="accompanyingCourse.step === 'CONFIRMED'"></start-date>
|
||||||
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
|
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
|
||||||
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
|
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ import Referrer from './components/Referrer.vue';
|
|||||||
import Resources from './components/Resources.vue';
|
import Resources from './components/Resources.vue';
|
||||||
import Comment from './components/Comment.vue';
|
import Comment from './components/Comment.vue';
|
||||||
import Confirm from './components/Confirm.vue';
|
import Confirm from './components/Confirm.vue';
|
||||||
|
import StartDate from './components/StartDate.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
@ -56,6 +58,7 @@ export default {
|
|||||||
Resources,
|
Resources,
|
||||||
Comment,
|
Comment,
|
||||||
Confirm,
|
Confirm,
|
||||||
|
StartDate
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState([
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
<template>
|
||||||
|
<div class="vue-component">
|
||||||
|
<h2><a id="section-110"></a>
|
||||||
|
{{ $t('startdate.change') }}
|
||||||
|
</h2>
|
||||||
|
<div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label class="col-form-label col-sm-4">{{ $t('startdate.date') }}</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input class="form-control" type="date" v-model="startDate" @change="updateStartDate" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import { datetimeToISO, ISOToDate} from 'ChillMainAssets/chill/js/date.js';
|
||||||
|
import { mapState, mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'startDate',
|
||||||
|
methods: {
|
||||||
|
updateStartDate(event) {
|
||||||
|
const date = event.target.value;
|
||||||
|
console.log(date)
|
||||||
|
this.$store.dispatch('updateStartDate', date)
|
||||||
|
.catch(({name, violations}) => {
|
||||||
|
if (name === 'ValidationException' || name === 'AccessException') {
|
||||||
|
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||||
|
} else {
|
||||||
|
this.$toast.open({message: 'An error occurred'})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
startDate() {
|
||||||
|
console.log(datetimeToISO(this.$store.state.accompanyingCourse.openingDate))
|
||||||
|
return datetimeToISO(this.$store.state.accompanyingCourse.openingDate)
|
||||||
|
}
|
||||||
|
// ...mapState({
|
||||||
|
// startDate: state => dateToISO(state.accompanyingCourse.openingDate)
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
@ -151,6 +151,10 @@ const appMessages = {
|
|||||||
placeholder: "Choisir un métier",
|
placeholder: "Choisir un métier",
|
||||||
not_valid: "Sélectionnez un métier du référent"
|
not_valid: "Sélectionnez un métier du référent"
|
||||||
},
|
},
|
||||||
|
startdate: {
|
||||||
|
change: "Modifier la date de début",
|
||||||
|
date: "Date de début",
|
||||||
|
},
|
||||||
// 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.",
|
||||||
|
@ -8,6 +8,7 @@ import { getAccompanyingCourse,
|
|||||||
import { patchPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
|
import { patchPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
|
||||||
import { patchThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
|
import { patchThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
|
||||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||||
|
import { datetimeToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
|
||||||
|
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
@ -278,6 +279,10 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
if (scopeIds.includes(scope.id)) {
|
if (scopeIds.includes(scope.id)) {
|
||||||
state.scopesAtBackend = state.scopesAtBackend.filter(s => s.id !== scope.id);
|
state.scopesAtBackend = state.scopesAtBackend.filter(s => s.id !== scope.id);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateStartDate(state, date) {
|
||||||
|
console.log('new state date', date)
|
||||||
|
state.accompanyingCourse.openingDate.datetime = date;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -701,6 +706,21 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise])
|
|||||||
throw error;
|
throw error;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
updateStartDate({commit}, payload) {
|
||||||
|
console.log('payload', payload)
|
||||||
|
const date = ISOToDate(payload);
|
||||||
|
const url = `/api/1.0/person/accompanying-course/${id}.json`;
|
||||||
|
const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }};
|
||||||
|
console.log('body', body)
|
||||||
|
return makeFetch('PATCH', url, body)
|
||||||
|
.then((response) => {
|
||||||
|
commit('updateStartDate', ISOToDatetime(response.openingDate.datetime));
|
||||||
|
})
|
||||||
|
.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