CommonDialogActionFooter.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import CommonButton, {
  4. type Props as ButtonProps,
  5. } from '#desktop/components/CommonButton/CommonButton.vue'
  6. export interface Props {
  7. hideActionButton?: boolean
  8. actionLabel?: string
  9. actionButton?: Pick<ButtonProps, 'prefixIcon' | 'variant'>
  10. hideCancelButton?: boolean
  11. cancelLabel?: string
  12. cancelButton?: Pick<ButtonProps, 'prefixIcon' | 'variant'>
  13. }
  14. withDefaults(defineProps<Props>(), {
  15. actionLabel: __('OK'),
  16. cancelLabel: __('Cancel & Go Back'),
  17. })
  18. const emit = defineEmits<{
  19. cancel: []
  20. action: []
  21. }>()
  22. const cancel = () => {
  23. emit('cancel')
  24. }
  25. const action = () => {
  26. emit('action')
  27. }
  28. </script>
  29. <template>
  30. <!-- TODO: rtl button order? -->
  31. <div
  32. class="flex items-center gap-2 ltr:justify-end rtl:flex-row-reverse rtl:justify-start"
  33. >
  34. <CommonButton
  35. v-if="!hideCancelButton"
  36. size="large"
  37. :prefix-icon="cancelButton?.prefixIcon"
  38. :variant="cancelButton?.variant || 'secondary'"
  39. @click="cancel()"
  40. >
  41. {{ $t(cancelLabel) }}
  42. </CommonButton>
  43. <CommonButton
  44. v-if="!hideActionButton"
  45. size="large"
  46. :prefix-icon="actionButton?.prefixIcon"
  47. :variant="actionButton?.variant || 'primary'"
  48. @click="action()"
  49. >
  50. {{ $t(actionLabel) }}
  51. </CommonButton>
  52. </div>
  53. </template>