From 96ffa05fa662ea694ea771794a848c9e6b376ed9 Mon Sep 17 00:00:00 2001
From: mishu
Date: Tue, 8 May 2018 13:37:47 +0300
Subject: [PATCH] closes #60
---
src/config/datatable.php | 2 ++
.../enso/vuedatatable/TableBody.vue | 2 +-
.../enso/vuedatatable/TopControls.vue | 25 +++++++++++++++++--
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/config/datatable.php b/src/config/datatable.php
index c1e5eb51..4e0ff9c1 100644
--- a/src/config/datatable.php
+++ b/src/config/datatable.php
@@ -79,6 +79,8 @@
'action' => 'ajax',
'method' => 'PATCH',
'label' => 'Action',
+ 'message' => 'Custom Action. Are you sure?',
+ 'confirmation' => true,
],
],
'row' => [
diff --git a/src/resources/assets/js/components/enso/vuedatatable/TableBody.vue b/src/resources/assets/js/components/enso/vuedatatable/TableBody.vue
index ccb36819..0f62212a 100644
--- a/src/resources/assets/js/components/enso/vuedatatable/TableBody.vue
+++ b/src/resources/assets/js/components/enso/vuedatatable/TableBody.vue
@@ -197,7 +197,7 @@ export default {
},
doAction(button, row) {
if (this.modal) {
- this.modal = false;
+ this.closeModal();
}
if (button.event) {
diff --git a/src/resources/assets/js/components/enso/vuedatatable/TopControls.vue b/src/resources/assets/js/components/enso/vuedatatable/TopControls.vue
index 73907daf..fff24bb4 100644
--- a/src/resources/assets/js/components/enso/vuedatatable/TopControls.vue
+++ b/src/resources/assets/js/components/enso/vuedatatable/TopControls.vue
@@ -16,7 +16,7 @@
:class="button.class"
:key="button.label"
:href="button.action === 'href' ? button.path : null"
- @click="doAction(button)">
+ @click="button.confirmation ? showModal(button) : doAction(button)">
{{ i18n(button.label) }}
@@ -74,6 +74,12 @@
+
@@ -86,6 +92,7 @@ import LengthMenu from './topControls/LengthMenu.vue';
import ColumnVisibility from './topControls/ColumnVisibility.vue';
import Alignment from './topControls/Alignment.vue';
import StyleSelector from './topControls/StyleSelector.vue';
+import Modal from './Modal.vue';
fontawesome.library.add(faSync, faUndo, faSearch, faInfoCircle);
@@ -93,7 +100,7 @@ export default {
name: 'TopControls',
components: {
- LengthMenu, ColumnVisibility, Alignment, StyleSelector,
+ LengthMenu, ColumnVisibility, Alignment, StyleSelector, Modal,
},
props: {
@@ -127,11 +134,25 @@ export default {
return {
lengthMenu: false,
columnVisibility: false,
+ modal: false,
+ button: null,
};
},
methods: {
+ showModal(button) {
+ this.button = button;
+ this.modal = true;
+ },
+ closeModal() {
+ this.modal = false;
+ this.button = null;
+ },
doAction(button) {
+ if (this.modal) {
+ this.closeModal();
+ }
+
this.$emit(button.event);
if (button.action === 'export') {