mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
closeParticipation fetch DELETE request
This commit is contained in:
parent
e6fcb5ff22
commit
e78d53064b
@ -351,7 +351,7 @@ class AccompanyingPeriod
|
||||
{
|
||||
foreach ($this->participations as $participation) {
|
||||
/** @var AccompanyingPeriodParticipation $participation */
|
||||
if ($person === $participation->getPerson() && $participation->getClosingDate() === NULL) {
|
||||
if ($person === $participation->getPerson() && $participation->getEndDate() === NULL) {
|
||||
return $participation;
|
||||
}}
|
||||
|
||||
|
@ -22,16 +22,16 @@
|
||||
:title="$t('action.edit')">
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<!--li>
|
||||
<button class="sc-button bt-delete"
|
||||
:title="$t('action.delete')"
|
||||
@click.prevent="$emit('remove', participation)">
|
||||
</button>
|
||||
</li>
|
||||
</li-->
|
||||
<li>
|
||||
<button class="sc-button bt-remove"
|
||||
:title="$t('action.remove')"
|
||||
@click="closeParticipation">
|
||||
@click.prevent="$emit('close', participation)">
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
@ -51,11 +51,6 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
emits: ['remove'],
|
||||
methods: {
|
||||
closeParticiapation() {
|
||||
|
||||
}
|
||||
}
|
||||
emits: ['remove', 'close']
|
||||
}
|
||||
</script>
|
||||
|
@ -17,7 +17,8 @@
|
||||
v-for="participation in participations"
|
||||
v-bind:participation="participation"
|
||||
v-bind:key="participation.id"
|
||||
@remove="removeParticipation">
|
||||
@remove="removeParticipation"
|
||||
@close="closeParticipation">
|
||||
</person-item>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -51,6 +52,10 @@ export default {
|
||||
removeParticipation(item) {
|
||||
this.$store.dispatch('removeParticipation', item)
|
||||
},
|
||||
closeParticipation(item) {
|
||||
console.log('@@ CLICK close participation: item', item);
|
||||
this.$store.dispatch('closeParticipation', item)
|
||||
},
|
||||
/*
|
||||
savePersons() {
|
||||
console.log('[wip] saving persons');
|
||||
|
@ -31,18 +31,18 @@ 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, item) {
|
||||
closeParticipation(state, { participation, item }) {
|
||||
console.log('mutation: close item', item.id);
|
||||
let participation = state.accompanying_course.participations.filter(participation => participation === item);
|
||||
console.log('participation', participation);
|
||||
state.accompanying_course.participations.filter(participation => participation !== item);
|
||||
//console.log('participation', participation);
|
||||
},
|
||||
addParticipation(state, { participation, payload }) {
|
||||
addParticipation(state, { participation, item }) {
|
||||
//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 !== payload);
|
||||
state.add_persons.selected = state.add_persons.selected.filter(value => value !== item);
|
||||
//console.log('après', state.add_persons.selected);
|
||||
|
||||
state.add_persons.query = "";
|
||||
@ -65,9 +65,21 @@ let getDataPromise = getAccompanyingCourse(id)
|
||||
removeParticipation({ commit }, payload) {
|
||||
commit('removeParticipation', payload);
|
||||
},
|
||||
closeParticipation({ commit }, payload) {
|
||||
console.log('## action: fetch delete participation: payload', payload.person.id);
|
||||
postParticipation(id, payload.person.id, 'DELETE')
|
||||
.then(participation => new Promise((resolve, reject) => {
|
||||
commit('closeParticipation', { participation, payload });
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => { // si y a une erreur
|
||||
//commit('removeParticipation', payload);
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
},
|
||||
addParticipation({ commit }, payload) {
|
||||
console.log('## action: fetch post participation: payload', payload.id);
|
||||
postParticipation(id, payload.id, 'POST')
|
||||
console.log('## action: fetch post participation: payload', payload.person.id);
|
||||
postParticipation(id, payload.person.id, 'POST')
|
||||
.then(participation => new Promise((resolve, reject) => {
|
||||
commit('addParticipation', { participation, payload });
|
||||
resolve();
|
||||
|
@ -118,7 +118,7 @@ export default {
|
||||
addPersons() {
|
||||
console.log('@@@ CLICK button addPersons')
|
||||
this.selected.forEach(function(item) {
|
||||
console.log('# dispatch action for each item', item);
|
||||
//console.log('# dispatch action for each item', item);
|
||||
this.$store.dispatch('addParticipation', item);
|
||||
}, this
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user