Confirm.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <script setup lang="ts">
  2. import { useStore } from "vuex";
  3. import { onBeforeUnmount } from "vue";
  4. import { useModalState, useModalActions } from "@/vuex_helpers";
  5. const props = defineProps({
  6. modalUuid: { type: String, default: "" }
  7. });
  8. const store = useStore();
  9. const { message } = useModalState("modals/confirm/MODAL_UUID", {
  10. modalUuid: props.modalUuid
  11. });
  12. const { confirm } = useModalActions("modals/confirm/MODAL_UUID", ["confirm"], {
  13. modalUuid: props.modalUuid
  14. });
  15. const closeCurrentModal = () =>
  16. store.dispatch("modalVisibility/closeCurrentModal");
  17. const confirmAction = () => {
  18. confirm();
  19. closeCurrentModal();
  20. };
  21. onBeforeUnmount(() => {
  22. // Delete the VueX module that was created for this modal, after all other cleanup tasks are performed
  23. store.unregisterModule(["modals", "confirm", props.modalUuid]);
  24. });
  25. </script>
  26. <template>
  27. <div>
  28. <modal class="confirm-modal" title="Confirm Action" :size="'slim'">
  29. <template #body>
  30. <div class="confirm-modal-inner-container">
  31. {{ message }}
  32. </div>
  33. </template>
  34. <template #footer>
  35. <button class="button is-danger" @click="confirmAction()">
  36. <i class="material-icons icon-with-button">warning</i>
  37. Confirm
  38. </button>
  39. </template>
  40. </modal>
  41. </div>
  42. </template>