aboutsummaryrefslogtreecommitdiff
path: root/src/components/confirm_modal
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/confirm_modal')
-rw-r--r--src/components/confirm_modal/confirm_modal.js37
-rw-r--r--src/components/confirm_modal/confirm_modal.vue29
2 files changed, 66 insertions, 0 deletions
diff --git a/src/components/confirm_modal/confirm_modal.js b/src/components/confirm_modal/confirm_modal.js
new file mode 100644
index 00000000..96ddc118
--- /dev/null
+++ b/src/components/confirm_modal/confirm_modal.js
@@ -0,0 +1,37 @@
+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
+ },
+ props: {
+ title: {
+ type: String
+ },
+ cancelText: {
+ type: String
+ },
+ confirmText: {
+ type: String
+ }
+ },
+ computed: {
+ },
+ methods: {
+ onCancel () {
+ this.$emit('cancelled')
+ },
+ onAccept () {
+ this.$emit('accepted')
+ }
+ }
+}
+
+export default ConfirmModal
diff --git a/src/components/confirm_modal/confirm_modal.vue b/src/components/confirm_modal/confirm_modal.vue
new file mode 100644
index 00000000..3b98174a
--- /dev/null
+++ b/src/components/confirm_modal/confirm_modal.vue
@@ -0,0 +1,29 @@
+<template>
+ <dialog-modal
+ v-body-scroll-lock="true"
+ class="confirm-modal"
+ :on-cancel="onCancel"
+ >
+ <template #header>
+ <span v-text="title" />
+ </template>
+
+ <slot />
+
+ <template #footer>
+ <button
+ class="btn button-default"
+ @click.prevent="onAccept"
+ v-text="confirmText"
+ />
+
+ <button
+ class="btn button-default"
+ @click.prevent="onCancel"
+ v-text="cancelText"
+ />
+ </template>
+ </dialog-modal>
+</template>
+
+<script src="./confirm_modal.js"></script>