Add ConfirmModal comp
This commit is contained in:
parent
a0b886459b
commit
0684f19d1b
2 changed files with 70 additions and 0 deletions
42
src/components/confirm_modal/confirm_modal.js
Normal file
42
src/components/confirm_modal/confirm_modal.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
import DialogModal from '../dialog_modal/dialog_modal.vue'
|
||||
|
||||
/**
|
||||
* This component emits the following events:
|
||||
* cancelled, emitted when the action should not be performed;
|
||||
* accepted, emitted when the action should be performed;
|
||||
*
|
||||
* The caller should close this dialog after receiving any of the two events.
|
||||
*/
|
||||
const ConfirmModal = {
|
||||
components: {
|
||||
DialogModal
|
||||
},
|
||||
data: {
|
||||
},
|
||||
props: {
|
||||
showing: {
|
||||
type: Boolean
|
||||
},
|
||||
title: {
|
||||
type: String
|
||||
},
|
||||
cancelText: {
|
||||
type: String
|
||||
},
|
||||
confirmText: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
methods: {
|
||||
onCancel () {
|
||||
this.$emit('cancelled')
|
||||
},
|
||||
onAccept () {
|
||||
this.$emit('accepted')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ConfirmModal
|
28
src/components/confirm_modal/confirm_modal.vue
Normal file
28
src/components/confirm_modal/confirm_modal.vue
Normal file
|
@ -0,0 +1,28 @@
|
|||
<template>
|
||||
<dialog-modal
|
||||
v-if="showing"
|
||||
:onCancel="onCancel"
|
||||
>
|
||||
<template v-slot:header>
|
||||
<span v-text="title"></span>
|
||||
</template>
|
||||
|
||||
<slot></slot>
|
||||
|
||||
<template v-slot:footer>
|
||||
<button
|
||||
class="btn button-default"
|
||||
v-text="confirmText"
|
||||
@click.prevent="onAccept"
|
||||
></button>
|
||||
|
||||
<button
|
||||
class="btn button-default"
|
||||
v-text="cancelText"
|
||||
@click.prevent="onCancel"
|
||||
></button>
|
||||
</template>
|
||||
</dialog-modal>
|
||||
</template>
|
||||
|
||||
<script src="./confirm_modal.js"></script>
|
Loading…
Reference in a new issue