addNewPersons() method is called out of addPerson component

note: this allow to use same addPersons component
to add participations, requestor, or interlocutors
This commit is contained in:
Mathieu Jaumotte 2021-05-08 12:12:58 +02:00
parent 0f59be04a7
commit b24eb93c57
3 changed files with 35 additions and 15 deletions

View File

@ -23,7 +23,10 @@
</tbody>
</table>
<add-persons buttonTitle="persons_associated.add_persons"></add-persons>
<add-persons
buttonTitle="persons_associated.add_persons"
@addNewPersons="addNewPersons">
</add-persons>
</div>
</template>
@ -45,11 +48,20 @@ export default {
}),
methods: {
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)
this.$store.dispatch('closeParticipation', item);
},
addNewPersons({ selected, modal }) {
console.log('@@@ CLICK button addNewPersons', selected);
selected.forEach(function(item) {
//console.log('# dispatch action for each item', item);
this.$store.dispatch('addParticipation', item);
}, this
);
modal.showModal = false;
}
}
}

View File

@ -38,7 +38,10 @@
</div>
</div>
<add-persons buttonTitle="requestor.add_requestor"></add-persons>
<add-persons
buttonTitle="requestor.add_requestor"
@addNewPersons="addNewPersons">
</add-persons>
</div>
</template>
@ -59,6 +62,18 @@ export default {
accompanyingCourse() {
return this.$store.state.accompanyingCourse
}
},
methods: {
addNewPersons({ selected, modal }) {
console.log('@@@ CLICK button addNewPersons', selected);
selected.forEach(function(item) {
//console.log('# dispatch action for each item', item);
console.log('HU-HUE, we want add new requestor !!', item);
//this.$store.dispatch('addRequestor', item);
}, this
);
modal.showModal = false;
}
}
}
</script>

View File

@ -55,7 +55,8 @@
</template>
<template v-slot:footer>
<button class="sc-button green" @click="addNewPersons">
<button class="sc-button green"
@click.prevent="$emit('addNewPersons', { selected, modal })">
<i class="fa fa-plus fa-fw"></i>{{ $t('action.add')}}
</button>
</template>
@ -119,16 +120,8 @@ export default {
this.$nextTick(function() {
this.$refs.search.focus();
})
},
addNewPersons() {
console.log('@@@ CLICK button addNewPersons')
this.selected.forEach(function(item) {
//console.log('# dispatch action for each item', item);
this.$store.dispatch('addParticipation', item);
}, this
);
this.modal.showModal = false;
}
}
},
emits: ['addNewPersons'],
}
</script>