ConfirmModal.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. dialog
  5. :title="$t('modal.confirm')"
  6. role="dialog"
  7. aria-modal="true"
  8. @close="hideModal"
  9. >
  10. <template #body>
  11. <div class="flex flex-col px-2">
  12. <label>
  13. {{ title }}
  14. </label>
  15. </div>
  16. </template>
  17. <template #footer>
  18. <span>
  19. <ButtonPrimary
  20. v-focus
  21. :label="yes"
  22. :loading="!!loadingState"
  23. @click.native="resolve"
  24. />
  25. <ButtonSecondary :label="no" @click.native="hideModal" />
  26. </span>
  27. </template>
  28. </SmartModal>
  29. </template>
  30. <script>
  31. import { defineComponent } from "@nuxtjs/composition-api"
  32. export default defineComponent({
  33. props: {
  34. show: Boolean,
  35. title: { type: String, default: null },
  36. yes: {
  37. type: String,
  38. default() {
  39. return this.$t("action.yes")
  40. },
  41. },
  42. no: {
  43. type: String,
  44. default() {
  45. return this.$t("action.no")
  46. },
  47. },
  48. loadingState: { type: Boolean, default: null },
  49. },
  50. methods: {
  51. hideModal() {
  52. this.$emit("hide-modal")
  53. },
  54. resolve() {
  55. this.$emit("resolve", this.title)
  56. if (this.loadingState === null) this.$emit("hide-modal")
  57. },
  58. },
  59. })
  60. </script>