CommonFlyoutActionFooter.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { toRef } from 'vue'
  4. import { useForm } from '#shared/components/Form/useForm.ts'
  5. import CommonButton from '#desktop/components/CommonButton/CommonButton.vue'
  6. import type { ActionFooterOptions as Props } from './types.ts'
  7. const props = withDefaults(defineProps<Props>(), {
  8. actionLabel: __('Update'),
  9. cancelLabel: __('Cancel & Go Back'),
  10. })
  11. const emit = defineEmits<{
  12. cancel: []
  13. action: []
  14. }>()
  15. const { isDisabled, formNodeId } = useForm(toRef(props, 'form'))
  16. const cancel = () => {
  17. emit('cancel')
  18. }
  19. const execute = () => {
  20. emit('action')
  21. }
  22. </script>
  23. <template>
  24. <div class="flex items-center justify-end gap-4">
  25. <CommonButton
  26. v-if="!hideCancelButton"
  27. size="large"
  28. :disabled="isDisabled || cancelButton?.disabled"
  29. :prefix-icon="cancelButton?.prefixIcon"
  30. :variant="cancelButton?.variant || 'secondary'"
  31. @click="cancel()"
  32. >
  33. {{ $t(cancelLabel) }}
  34. </CommonButton>
  35. <CommonButton
  36. v-if="!hideActionButton"
  37. size="large"
  38. :disabled="isDisabled || actionButton?.disabled"
  39. :form="formNodeId"
  40. :type="actionButton?.type"
  41. :prefix-icon="actionButton?.prefixIcon"
  42. :variant="actionButton?.variant || 'submit'"
  43. @click="execute()"
  44. >
  45. {{ $t(actionLabel) }}
  46. </CommonButton>
  47. </div>
  48. </template>