From ee817b1d6293f42809451c6129d36b812675f7b5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 9 Feb 2022 17:56:53 +0100 Subject: [PATCH] url's and method changed for toggleIntensity and toggleConfidential --- .../components/Banner/ToggleFlags.vue | 26 ++++++++--------- .../vuejs/AccompanyingCourse/store/index.js | 29 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue index 39fe50acc..490bf4d9f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue @@ -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'}) + } + }); }, }, } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 0f682e86a..70efe9720 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -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);