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:
2023-04-11 10:45:10 +02:00
parent ef13833966
commit 98aad8c4b6
7 changed files with 36 additions and 16 deletions

View File

@@ -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);

View File

@@ -15,7 +15,7 @@ const app = createApp({
.use(VueToast, {
position: "bottom-right",
type: "error",
duration: 5000,
duration: 10000,
dismissible: true
})
.use(i18n)

View File

@@ -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) {