for each selected, loop for post participation, then get response and commit state

This commit is contained in:
2021-05-04 22:30:22 +02:00
parent 120e7cade5
commit 30f490959b
6 changed files with 78 additions and 49 deletions

View File

@@ -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 v-if="suggestedCounter > 0" style="">
@@ -61,6 +61,8 @@ import { mapState } from 'vuex';
import Modal from 'ChillPersonAssets/vuejs/_components/Modal';
import PersonSuggestion from 'ChillPersonAssets/vuejs/_components/PersonSuggestion';
const SimpsonId = 10000;
export default {
name: 'AddPersons',
components: {
@@ -75,14 +77,6 @@ export default {
}
}
},
methods: {
openModal() {
this.modal.showModal = true;
this.$nextTick(function() {
this.$refs.search.focus();
})
}
},
computed: {
...mapState(['add_persons']),
query: {
@@ -109,20 +103,21 @@ export default {
selectedAndSuggested() {
return [...new Set([...this.selected, ...this.suggested])];
},
},
methods: {
openModal() {
this.modal.showModal = true;
this.$nextTick(function() {
this.$refs.search.focus();
})
},
addPersons() {
console.log('add persons');
// code here
/*
addPerson() {
console.log('[wip] opening add persons modal');
this.$store.dispatch('addParticipation', {
id: SimpsonId++,
person: { firstName: "Lisa", lastName: "Simpson", id: SimpsonId },
startDate: { datetime: "1975-09-15T00:00:00+0100" },
endDate: { datetime: "1975-09-28T00:00:00+0100" },
})
},
*/
console.log('@@@ CLICK button addPersons')
this.selected.forEach(function(item) {
console.log('# dispatch action for each item', item);
this.$store.dispatch('addParticipation', item);
}, this
);
this.modal.showModal = false;
}
}