2020-02-25 12:08:48 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import ConfirmModal from '~/vue_shared/components/confirm_modal.vue';
|
|
|
|
|
2020-03-06 09:08:13 +00:00
|
|
|
const mountConfirmModal = () => {
|
2020-02-25 12:08:48 +00:00
|
|
|
return new Vue({
|
2020-03-06 09:08:13 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
path: '',
|
|
|
|
method: '',
|
|
|
|
modalAttributes: null,
|
|
|
|
showModal: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
document.querySelectorAll('.js-confirm-modal-button').forEach(button => {
|
|
|
|
button.addEventListener('click', e => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
this.path = button.dataset.path;
|
|
|
|
this.method = button.dataset.method;
|
|
|
|
this.modalAttributes = JSON.parse(button.dataset.modalAttributes);
|
|
|
|
this.showModal = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
dismiss() {
|
|
|
|
this.showModal = false;
|
|
|
|
},
|
|
|
|
},
|
2020-02-25 12:08:48 +00:00
|
|
|
render(h) {
|
2020-03-06 09:08:13 +00:00
|
|
|
return h(ConfirmModal, {
|
|
|
|
props: {
|
|
|
|
path: this.path,
|
|
|
|
method: this.method,
|
|
|
|
modalAttributes: this.modalAttributes,
|
|
|
|
showModal: this.showModal,
|
|
|
|
},
|
|
|
|
on: { dismiss: this.dismiss },
|
|
|
|
});
|
2020-02-25 12:08:48 +00:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
};
|
|
|
|
|
2020-03-06 09:08:13 +00:00
|
|
|
export default () => mountConfirmModal();
|