mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improve addpersons store cycle: init query, selections and suggestions
This commit is contained in:
parent
3b53c4451c
commit
1bbec9efae
@ -22,6 +22,9 @@ let getDataPromise = getAccompanyingCourse(id)
|
||||
errorMsg: []
|
||||
},
|
||||
getters: {
|
||||
getSelectedByid: (state) => (id) => {
|
||||
return state.add_persons.selected.find(item => item.id === id)
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
removeParticipation(state, item) {
|
||||
@ -30,20 +33,17 @@ let getDataPromise = getAccompanyingCourse(id)
|
||||
participation => participation !== item
|
||||
);
|
||||
},
|
||||
addParticipation(state, participation) {
|
||||
console.log('### mutation: add participation', participation);
|
||||
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('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 !== payload);
|
||||
//console.log('après', state.add_persons.selected);
|
||||
|
||||
let item = { id: participation.person.id, text: participation.person.firstName + ' ' + participation.person.lastName };
|
||||
console.log('item', item);
|
||||
console.log('avant', state.add_persons.selected.length);
|
||||
state.add_persons.selected = state.add_persons.selected.filter(value => value !== item);
|
||||
console.log('après', state.add_persons.selected.length);
|
||||
},
|
||||
resetQuery() {
|
||||
console.log('### mutation: reset query');
|
||||
state.add_persons.query = "";
|
||||
state.add_persons.suggested = [];
|
||||
},
|
||||
setQuery(state, query) {
|
||||
//console.log('q=', query);
|
||||
@ -66,7 +66,7 @@ let getDataPromise = getAccompanyingCourse(id)
|
||||
console.log('## action: fetch post participation: payload', payload.id);
|
||||
postParticipation(id, payload.id, 'POST')
|
||||
.then(participation => new Promise((resolve, reject) => {
|
||||
commit('addParticipation', participation);
|
||||
commit('addParticipation', { participation, payload });
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => { // si y a une erreur
|
||||
|
@ -28,7 +28,7 @@
|
||||
</template>
|
||||
|
||||
<template v-slot:body>
|
||||
<span class="discret">Selection: {{ selected }}</span>
|
||||
<!--span class="discret">Selection: {{ selected }}</span-->
|
||||
<div class="results">
|
||||
<div class="count">
|
||||
<span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user