ApplyTemplate.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { useSessionStore } from '#shared/stores/session.ts'
  5. import CommonDropdown from '#desktop/components/CommonDropdown/CommonDropdown.vue'
  6. import type { DropdownItem } from '#desktop/components/CommonDropdown/types.ts'
  7. import { useApplyTemplate } from '../composables/useApplyTemplate.ts'
  8. const emit = defineEmits<{
  9. 'select-template': [string]
  10. }>()
  11. const { hasPermission } = useSessionStore()
  12. const { templateList } = useApplyTemplate()
  13. const templateAccess = computed(
  14. () =>
  15. templateList &&
  16. templateList.value.length > 0 &&
  17. hasPermission('ticket.agent'),
  18. )
  19. const items = computed<DropdownItem[]>(() =>
  20. templateList.value.map((template) => ({
  21. key: template.id,
  22. label: template.name,
  23. })),
  24. )
  25. </script>
  26. <template>
  27. <template v-if="templateAccess">
  28. <CommonDropdown
  29. :items="items"
  30. :action-label="$t('Apply Template')"
  31. orientation="top"
  32. @handle-action="emit('select-template', $event.key)"
  33. />
  34. </template>
  35. </template>