CommonTicketStateList.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { TicketState } from '#shared/entities/ticket/types.ts'
  4. import { replaceTags } from '#shared/utils/formatter.ts'
  5. import CommonSectionMenu from '../CommonSectionMenu/CommonSectionMenu.vue'
  6. import CommonSectionMenuLink from '../CommonSectionMenu/CommonSectionMenuLink.vue'
  7. interface Props {
  8. createLink?: string
  9. createLabel?: string
  10. counts: Record<TicketState.Closed | TicketState.Open, number>
  11. ticketsLinkQuery: string
  12. }
  13. const props = defineProps<Props>()
  14. const getTicketsLink = (stateIds: number[]) => {
  15. const states = stateIds
  16. .map((stateId) => `state.state_type_id: ${stateId}`)
  17. .join(' OR ')
  18. return replaceTags(`/search/ticket?search=(${states}) AND #{query}`, {
  19. query: props.ticketsLinkQuery,
  20. })
  21. }
  22. </script>
  23. <template>
  24. <CommonSectionMenu header-label="Tickets">
  25. <div class="px-3">
  26. <slot name="before-fields" />
  27. </div>
  28. <CommonSectionMenuLink
  29. :icon="{
  30. name: 'check-circle-no',
  31. size: 'base',
  32. class: 'text-yellow',
  33. decorative: true,
  34. }"
  35. :information="counts[TicketState.Open]"
  36. :link="getTicketsLink([1, 2, 3, 4])"
  37. >
  38. {{ $t('open') }}
  39. </CommonSectionMenuLink>
  40. <CommonSectionMenuLink
  41. :icon="{
  42. name: 'check-circle-no',
  43. size: 'base',
  44. class: 'text-green',
  45. decorative: true,
  46. }"
  47. :information="counts[TicketState.Closed]"
  48. :link="getTicketsLink([5])"
  49. >
  50. {{ $t('closed') }}
  51. </CommonSectionMenuLink>
  52. <CommonLink
  53. v-if="createLink && createLabel"
  54. class="text-blue flex min-h-[54px] items-center justify-center gap-2"
  55. :link="createLink"
  56. >
  57. <CommonIcon name="add" size="tiny" decorative />
  58. {{ $t(createLabel) }}
  59. </CommonLink>
  60. </CommonSectionMenu>
  61. </template>