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