url's and method changed for toggleIntensity and toggleConfidential

This commit is contained in:
Julie Lenaerts 2022-02-09 17:56:53 +01:00
parent a399804094
commit ee817b1d62
2 changed files with 29 additions and 26 deletions

View File

@ -76,19 +76,19 @@ export default {
},
toggleConfidential() {
this.$store.dispatch('fetchPermissions').then(() => {
if (!this.$store.getters.canTogglePermission) {
this.$toast.open({message: "Seul le référent peut modifier la confidentialité"});
return Promise.resolve();
} else {
return this.$store.dispatch('toggleConfidential', (!this.isConfidential));
}
}).catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
if (!this.$store.getters.canTogglePermission) {
this.$toast.open({message: "Seul le référent peut modifier la confidentialité"});
return Promise.resolve();
} else {
return this.$store.dispatch('toggleConfidential', (!this.isConfidential));
}
}).catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
},
}

View File

@ -420,13 +420,13 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
const url = `/api/1.0/person/accompanying-course/resource/${id}.json`;
return makeFetch('PATCH', url, body)
.then((response) => {
commit('patchResource', response);
})
.catch((error) => {
commit('catchError', error);
throw error;
})
.then((response) => {
commit('patchResource', response);
})
.catch((error) => {
commit('catchError', error);
throw error;
})
},
/**
* On The Fly
@ -468,12 +468,12 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
* Update accompanying course intensity/emergency/confidentiality
*/
toggleIntensity({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const url = `/api/1.0/person/accompanying-course/${id}/intensity.json`
const body = { type: "accompanying_period", 'intensity': payload }
return makeFetch('PATCH', url, body)
return makeFetch('POST', url, body)
.then((response) => {
commit('toggleIntensity', response.intensity);
commit('toggleIntensity', response);
})
.catch((error) => {
@ -495,12 +495,15 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
})
},
toggleConfidential({ commit }, payload) {
const url = `/api/1.0/person/accompanying-course/${id}.json`
const url = `/api/1.0/person/accompanying-course/${id}/confidential.json`
const body = { type: "accompanying_period", confidential: payload }
return makeFetch('PATCH', url, body)
console.log('url', url)
console.log('body', body)
return makeFetch('POST', url, body)
.then((response) => {
commit('toggleConfidential', response.confidential);
commit('toggleConfidential', response);
})
.catch((error) => {
commit('catchError', error);