From a536d2780e7be8951200828a0b7c518cfa2d2e64 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 6 May 2021 12:57:53 +0200 Subject: [PATCH] fix state mutation for closeParticipation --- .../components/PersonsAssociated.vue | 2 +- .../vuejs/AccompanyingCourse/store/index.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index 586ad3993..f330acde6 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -60,7 +60,7 @@ export default { savePersons() { console.log('[wip] saving persons'); } -*/ + */ } } 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 88b3d571b..9bf4d4014 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -31,16 +31,21 @@ let getDataPromise = getAccompanyingCourse(id) //console.log('mutation: remove item', item.id); state.accompanying_course.participations = state.accompanying_course.participations.filter(participation => participation !== item); }, - closeParticipation(state, { participation, item }) { - console.log('mutation: close item', item.id); - state.accompanying_course.participations.filter(participation => participation !== item); + closeParticipation(state, { participation, payload }) { + console.log('### mutation: close item', { participation, payload }); + // temporaire, le temps que le backend ajoute la enddate + participation.endDate = { datetime: "2021-05-06T10:49:00+0200" }; + // trouve dans le state le payload et le supprime du state + state.accompanying_course.participations = state.accompanying_course.participations.filter(participation => participation !== payload); + // pousse la participation + state.accompanying_course.participations.push(participation); }, - addParticipation(state, { participation, item }) { + addParticipation(state, { participation, payload }) { //console.log('### mutation: add participation', participation); state.accompanying_course.participations.push(participation); //console.log('count participations from state', state.accompanying_course.participations.length); //console.log('avant', state.add_persons.selected); - state.add_persons.selected = state.add_persons.selected.filter(value => value !== item); + state.add_persons.selected = state.add_persons.selected.filter(value => value !== payload); //console.log('après', state.add_persons.selected); state.add_persons.query = ""; state.add_persons.suggested = []; @@ -92,6 +97,7 @@ let getDataPromise = getAccompanyingCourse(id) console.log('## action: fetch delete participation: payload', payload.person.id); postParticipation(id, payload.person.id, 'DELETE') .then(participation => new Promise((resolve, reject) => { + //console.log('payload', payload); commit('closeParticipation', { participation, payload }); resolve(); }))