close modals when saving

This commit is contained in:
busti 2019-12-27 02:38:58 +01:00
parent d3a52aae06
commit 7131a54455
3 changed files with 6 additions and 5 deletions

View file

@ -0,0 +1,37 @@
<template>
<div>
<Modal v-if="isModal" title="Add Item" @close="$emit('close')">
<template #body>
<EditItem :item="item"/>
</template>
<template #buttons>
<button type="button" class="btn btn-secondary" @click="$emit('close')">Cancel</button>
<button type="button" class="btn btn-success" @click="saveNewItem()">Save new Item</button>
</template>
</Modal>
</div>
</template>
<script>
import Modal from '@/components/Modal';
import EditItem from '@/components/EditItem';
export default {
name: 'AddItemModal',
components: { Modal, EditItem },
props: ['isModal'],
data: () => ({
item: {}
}),
methods: {
saveNewItem() {
this.$store.dispatch('postItem', this.item);
this.$emit('close');
}
}
};
</script>
<style scoped>
</style>