TicketDetailViewTitle.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, toRef } from 'vue'
  4. import CommonOrganizationAvatar from '#shared/components/CommonOrganizationAvatar/CommonOrganizationAvatar.vue'
  5. import CommonUserAvatar from '#shared/components/CommonUserAvatar/CommonUserAvatar.vue'
  6. import { useTicketChannel } from '#shared/entities/ticket/composables/useTicketChannel.ts'
  7. import { useTicketView } from '#shared/entities/ticket/composables/useTicketView.ts'
  8. import type { TicketById } from '#shared/entities/ticket/types.ts'
  9. import { useLocaleStore } from '#shared/stores/locale.ts'
  10. import CommonTicketEscalationIndicator from '#mobile/components/CommonTicketEscalationIndicator/CommonTicketEscalationIndicator.vue'
  11. import CommonTicketPriorityIndicator from '#mobile/components/CommonTicketPriorityIndicator/CommonTicketPriorityIndicator.vue'
  12. import CommonTicketStateIndicator from '#mobile/components/CommonTicketStateIndicator/CommonTicketStateIndicator.vue'
  13. interface Props {
  14. ticket: TicketById
  15. }
  16. const props = defineProps<Props>()
  17. const ticketReactive = toRef(props, 'ticket')
  18. // TODO: Maybe in the future we can hide additional information (e.g. the priority) directly with the graphql query for
  19. // the ticket details (similar to the ticket list).
  20. const { isTicketAgent, isTicketEditable } = useTicketView(ticketReactive)
  21. const { hasChannelAlert, channelAlert } = useTicketChannel(ticketReactive)
  22. const locale = useLocaleStore()
  23. const customer = computed(() => {
  24. const { customer } = props.ticket
  25. if (!customer) return ''
  26. const { fullname } = customer
  27. if (fullname === '-') return ''
  28. return fullname
  29. })
  30. </script>
  31. <template>
  32. <div data-test-id="ticket-title" class="relative">
  33. <div class="border-b-[0.5px] border-white/10 bg-gray-600/90">
  34. <CommonLink
  35. class="flex px-4 py-5"
  36. data-test-id="title-content"
  37. :link="`/tickets/${ticket.internalId}/information`"
  38. >
  39. <div class="flex ltr:mr-3 rtl:ml-3">
  40. <CommonUserAvatar class="z-10" :entity="ticket.customer" />
  41. <CommonOrganizationAvatar
  42. v-if="ticket.organization"
  43. class="z-0 ltr:-translate-x-1 rtl:translate-x-1"
  44. :entity="ticket.organization"
  45. />
  46. </div>
  47. <div
  48. class="overflow-hidden ltr:mr-1 rtl:ml-1"
  49. :class="{ 'ltr:-ml-1 rtl:-mr-1': ticket.organization }"
  50. >
  51. <div class="flex text-sm leading-4 text-gray-100">
  52. <div
  53. class="truncate"
  54. :class="{
  55. 'max-w-[80vw]': !ticket.organization,
  56. 'max-w-[40vw]': ticket.organization,
  57. }"
  58. >
  59. {{ customer }}
  60. </div>
  61. <template v-if="ticket.organization">
  62. <div class="px-1">·</div>
  63. <div class="max-w-[40vw] truncate">
  64. {{ ticket.organization.name }}
  65. </div>
  66. </template>
  67. </div>
  68. <h1 class="line-clamp-3 break-words text-xl font-bold leading-7">
  69. {{ ticket.title }}
  70. </h1>
  71. <div class="mt-2 flex flex-wrap gap-2">
  72. <CommonTicketEscalationIndicator
  73. v-if="isTicketAgent && ticket.escalationAt"
  74. :escalation-at="ticket.escalationAt"
  75. />
  76. <CommonTicketStateIndicator
  77. :color-code="ticket.stateColorCode"
  78. :label="ticket.state.name"
  79. pill
  80. />
  81. <CommonTicketPriorityIndicator
  82. v-if="isTicketAgent"
  83. :priority="ticket.priority"
  84. />
  85. </div>
  86. </div>
  87. <CommonIcon
  88. :name="`chevron-${locale.localeData?.dir === 'rtl' ? 'left' : 'right'}`"
  89. size="base"
  90. class="shrink-0 self-center ltr:-mr-2 ltr:ml-auto rtl:-ml-2 rtl:mr-auto"
  91. decorative
  92. />
  93. </CommonLink>
  94. </div>
  95. <CommonAlert
  96. v-if="isTicketAgent && isTicketEditable && hasChannelAlert"
  97. class="rounded-b-lg"
  98. :variant="channelAlert?.variant"
  99. >
  100. {{ $t(channelAlert?.text, channelAlert?.textPlaceholder) }}
  101. </CommonAlert>
  102. </div>
  103. </template>