mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +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: []
|
errorMsg: []
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
getSelectedByid: (state) => (id) => {
|
||||||
|
return state.add_persons.selected.find(item => item.id === id)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
removeParticipation(state, item) {
|
removeParticipation(state, item) {
|
||||||
@ -30,20 +33,17 @@ let getDataPromise = getAccompanyingCourse(id)
|
|||||||
participation => participation !== item
|
participation => participation !== item
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
addParticipation(state, participation) {
|
addParticipation(state, { participation, payload }) {
|
||||||
console.log('### mutation: add participation', participation);
|
//console.log('### mutation: add participation', participation);
|
||||||
state.accompanying_course.participations.push(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.query = "";
|
||||||
|
state.add_persons.suggested = [];
|
||||||
},
|
},
|
||||||
setQuery(state, query) {
|
setQuery(state, query) {
|
||||||
//console.log('q=', query);
|
//console.log('q=', query);
|
||||||
@ -66,7 +66,7 @@ let getDataPromise = getAccompanyingCourse(id)
|
|||||||
console.log('## action: fetch post participation: payload', payload.id);
|
console.log('## action: fetch post participation: payload', payload.id);
|
||||||
postParticipation(id, payload.id, 'POST')
|
postParticipation(id, payload.id, 'POST')
|
||||||
.then(participation => new Promise((resolve, reject) => {
|
.then(participation => new Promise((resolve, reject) => {
|
||||||
commit('addParticipation', participation);
|
commit('addParticipation', { participation, payload });
|
||||||
resolve();
|
resolve();
|
||||||
}))
|
}))
|
||||||
.catch((error) => { // si y a une erreur
|
.catch((error) => { // si y a une erreur
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<span class="discret">Selection: {{ selected }}</span>
|
<!--span class="discret">Selection: {{ selected }}</span-->
|
||||||
<div class="results">
|
<div class="results">
|
||||||
<div class="count">
|
<div class="count">
|
||||||
<span>
|
<span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user