mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 08:03:49 +00:00
Fixed: [accompanying period work / edit] allow endDate to be equal to startDate, and show validation errors to users
Fix https://gitlab.com/Chill-Projet/chill-bundles/-/issues/79
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
import { createApp } from 'vue';
|
||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import { store } from './store';
|
||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||
import {createApp} from 'vue';
|
||||
import {_createI18n} from 'ChillMainAssets/vuejs/_js/i18n';
|
||||
import {store} from './store';
|
||||
import {personMessages} from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||
import App from './App.vue';
|
||||
import VueToast from "vue-toast-notification";
|
||||
|
||||
const i18n = _createI18n(personMessages);
|
||||
|
||||
const app = createApp({
|
||||
template: `<app></app>`,
|
||||
template: `<app></app>`,
|
||||
})
|
||||
.use(store)
|
||||
.use(i18n)
|
||||
.component('app', App)
|
||||
.mount('#accompanying_course_work_create');
|
||||
.use(store)
|
||||
.use(i18n)
|
||||
.use(VueToast, {
|
||||
position: "bottom-right",
|
||||
type: "error",
|
||||
duration: 10000,
|
||||
dismissible: true,
|
||||
})
|
||||
.component('app', App)
|
||||
.mount('#accompanying_course_work_create');
|
||||
|
@@ -107,6 +107,9 @@ const store = createStore({
|
||||
setPostingWork(state) {
|
||||
state.isPostingWork = true;
|
||||
},
|
||||
setPostingWorkDone(state) {
|
||||
state.isPostingWork = false;
|
||||
},
|
||||
setStartDate(state, date) {
|
||||
state.startDate = date;
|
||||
},
|
||||
@@ -150,11 +153,12 @@ const store = createStore({
|
||||
const url = `/api/1.0/person/accompanying-course/${state.accompanyingCourse.id}/work.json`;
|
||||
commit('setPostingWork');
|
||||
|
||||
makeFetch('POST', url, payload)
|
||||
return makeFetch('POST', url, payload)
|
||||
.then((response) => {
|
||||
window.location.assign(`/fr/person/accompanying-period/work/${response.id}/edit`)
|
||||
})
|
||||
.catch((error) => {
|
||||
commit('setPostingWorkDone');
|
||||
throw error;
|
||||
});
|
||||
},
|
||||
|
@@ -549,7 +549,14 @@ export default {
|
||||
.catch(e => { console.log(e); throw e; });
|
||||
},
|
||||
submit() {
|
||||
this.$store.dispatch('submit');
|
||||
this.$store.dispatch('submit').catch((error) => {
|
||||
if (error.name === 'ValidationException' || error.name === 'AccessException') {
|
||||
error.violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: 'An error occurred'});
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
},
|
||||
saveFormOnTheFly(payload) {
|
||||
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
|
||||
|
@@ -15,7 +15,7 @@ const app = createApp({
|
||||
.use(VueToast, {
|
||||
position: "bottom-right",
|
||||
type: "error",
|
||||
duration: 5000,
|
||||
duration: 10000,
|
||||
dismissible: true
|
||||
})
|
||||
.use(i18n)
|
||||
|
@@ -500,9 +500,8 @@ const store = createStore({
|
||||
window.location.assign(`/fr/person/accompanying-period/${state.work.accompanyingPeriod.id}/work`);
|
||||
}
|
||||
}).catch(error => {
|
||||
console.log('error on submit', error);
|
||||
commit('setIsPosting', false);
|
||||
commit('setErrors', error.violations);
|
||||
throw error;
|
||||
});
|
||||
},
|
||||
updateDocumentTitle({commit}, payload) {
|
||||
|
Reference in New Issue
Block a user