GuidedSetupActionFooter.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, toRef } from 'vue'
  4. import { type RouteLocationRaw, useRouter } from 'vue-router'
  5. import { useForm } from '#shared/components/Form/useForm.ts'
  6. import type { FormRef } from '#shared/components/Form/types.ts'
  7. import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
  8. import LayoutPublicPageBoxActions from '#desktop/components/layout/LayoutPublicPage/LayoutPublicPageBoxActions.vue'
  9. import type {
  10. ButtonType,
  11. ButtonVariant,
  12. } from '#desktop/components/CommonButton/types.ts'
  13. interface Props {
  14. form?: FormRef
  15. skipRoute?: RouteLocationRaw
  16. continueRoute?: RouteLocationRaw
  17. goBackRoute?: RouteLocationRaw
  18. onSkip?: () => void
  19. onContinue?: () => void
  20. onBack?: () => void
  21. onSubmit?: () => void
  22. submitButtonText?: string
  23. submitButtonVariant?: ButtonVariant
  24. submitButtonType?: ButtonType
  25. continueButtonText?: string
  26. }
  27. const props = withDefaults(defineProps<Props>(), {
  28. submitButtonVariant: 'submit',
  29. submitButtonType: 'submit',
  30. })
  31. const emit = defineEmits<{
  32. (e: 'submit'): void
  33. (e: 'back'): void
  34. (e: 'skip'): void
  35. (e: 'continue'): void
  36. }>()
  37. const router = useRouter()
  38. const { isDisabled, formNodeId } = useForm(toRef(props, 'form'))
  39. const localContinueButtonText = computed(() => {
  40. return props.continueButtonText || __('Continue')
  41. })
  42. const localSubmitButtonText = computed(() => {
  43. return props.submitButtonText || __('Submit')
  44. })
  45. const goBack = () => {
  46. if (props.onBack) emit('back')
  47. if (props.goBackRoute) router.push(props.goBackRoute)
  48. }
  49. const skip = () => {
  50. if (props.onSkip) emit('skip')
  51. if (props.skipRoute) router.push(props.skipRoute)
  52. }
  53. const cont = () => {
  54. if (props.onContinue) emit('continue')
  55. if (props.continueRoute) router.push(props.continueRoute)
  56. }
  57. const submit = () => {
  58. emit('submit')
  59. }
  60. </script>
  61. <template>
  62. <LayoutPublicPageBoxActions>
  63. <CommonButton
  64. v-if="goBackRoute || onBack"
  65. variant="secondary"
  66. size="large"
  67. :disabled="isDisabled"
  68. @click="goBack()"
  69. >
  70. {{ $t('Go Back') }}
  71. </CommonButton>
  72. <CommonButton
  73. v-if="skipRoute || onSkip"
  74. variant="tertiary"
  75. size="large"
  76. :disabled="isDisabled"
  77. @click="skip()"
  78. >
  79. {{ $t('Skip') }}
  80. </CommonButton>
  81. <CommonButton
  82. v-if="continueRoute || onContinue"
  83. variant="primary"
  84. size="large"
  85. :disabled="isDisabled"
  86. @click="cont()"
  87. >
  88. {{ $t(localContinueButtonText) }}
  89. </CommonButton>
  90. <CommonButton
  91. v-if="form || onSubmit"
  92. :type="submitButtonType"
  93. size="large"
  94. :variant="submitButtonVariant"
  95. :disabled="isDisabled"
  96. :form="formNodeId"
  97. @click="submit()"
  98. >
  99. {{ $t(localSubmitButtonText) }}
  100. </CommonButton>
  101. </LayoutPublicPageBoxActions>
  102. </template>