TicketCreate.vue 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { useTicketCreateArticleType } from '#shared/entities/ticket/composables/useTicketCreateArticleType.ts'
  5. import { useTicketCreateView } from '#shared/entities/ticket/composables/useTicketCreateView.ts'
  6. import type { TicketCreateArticleType } from '#shared/entities/ticket/types.ts'
  7. import { type UserTaskbarItemEntityTicketCreate } from '#shared/graphql/types.ts'
  8. import { i18n } from '#shared/i18n.ts'
  9. import { useUserTaskbarTabLink } from '#desktop/composables/useUserTaskbarTabLink.ts'
  10. import type { UserTaskbarTabEntityProps } from '../types.ts'
  11. const props =
  12. defineProps<UserTaskbarTabEntityProps<UserTaskbarItemEntityTicketCreate>>()
  13. const { ticketCreateArticleType, defaultTicketCreateArticleType } =
  14. useTicketCreateArticleType()
  15. const { isTicketCustomer } = useTicketCreateView()
  16. const { tabLinkInstance } = useUserTaskbarTabLink()
  17. const currentViewTitle = computed(() => {
  18. // Customer users should get a generic title prefix, since they cannot control the type of the first article.
  19. if (isTicketCustomer.value) {
  20. if (!props.context?.formValues?.title && !props.taskbarTab.entity?.title)
  21. return i18n.t('New Ticket')
  22. return i18n.t(
  23. 'New Ticket: %s',
  24. (props.context?.formValues?.title as string) ||
  25. props.taskbarTab.entity?.title,
  26. )
  27. }
  28. if (
  29. !props.context?.formValues?.articleSenderType &&
  30. !props.taskbarTab.entity?.createArticleTypeKey
  31. )
  32. return i18n.t(
  33. ticketCreateArticleType[defaultTicketCreateArticleType]?.label,
  34. )
  35. const createArticleTypeKey = (props.context?.formValues?.articleSenderType ||
  36. props.taskbarTab.entity?.createArticleTypeKey) as TicketCreateArticleType
  37. if (!props.context?.formValues?.title && !props.taskbarTab.entity?.title)
  38. return i18n.t(ticketCreateArticleType[createArticleTypeKey]?.label)
  39. return i18n.t(
  40. ticketCreateArticleType[createArticleTypeKey]?.title,
  41. (props.context?.formValues?.title as string) ||
  42. props.taskbarTab.entity?.title,
  43. )
  44. })
  45. </script>
  46. <template>
  47. <CommonLink
  48. v-if="taskbarTabLink"
  49. ref="tabLinkInstance"
  50. v-tooltip="currentViewTitle"
  51. class="flex grow gap-2 rounded-md px-2 py-3 hover:no-underline focus-visible:rounded-md focus-visible:outline-none group-hover/tab:bg-blue-600 group-hover/tab:dark:bg-blue-900"
  52. :link="taskbarTabLink"
  53. exact-active-class="!bg-blue-800 text-white"
  54. internal
  55. >
  56. <CommonIcon
  57. class="-:text-stone-200 -:dark:text-neutral-500 shrink-0 group-focus-visible/link:text-white"
  58. name="pencil"
  59. size="small"
  60. decorative
  61. />
  62. <CommonLabel
  63. class="-:text-gray-300 -:dark:text-neutral-400 block truncate group-hover/tab:text-white group-focus-visible/link:text-white"
  64. >
  65. {{ currentViewTitle }}
  66. </CommonLabel>
  67. </CommonLink>
  68. </template>
  69. <style scoped>
  70. .router-link-active {
  71. @apply text-white;
  72. .icon,
  73. span {
  74. @apply text-white;
  75. }
  76. }
  77. </style>