TicketOverviewEditItem.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!-- Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import CommonTooltip from '#shared/components/CommonTooltip/CommonTooltip.vue'
  5. import type { TooltipItemDescriptor } from '#shared/components/CommonTooltip/types.ts'
  6. import type { TicketOverview } from '#mobile/entities/ticket/stores/ticketOverviews.ts'
  7. const props = defineProps<{
  8. action: 'add' | 'delete'
  9. draggable?: boolean
  10. overview: TicketOverview
  11. }>()
  12. const emit = defineEmits<{
  13. action: []
  14. 'action-active': [boolean]
  15. }>()
  16. const icon = computed(() => {
  17. if (props.action === 'add') {
  18. return {
  19. name: 'plus',
  20. class: 'text-green',
  21. }
  22. }
  23. return {
  24. name: 'minus',
  25. class: 'text-red',
  26. }
  27. })
  28. const hasTooltip = computed(
  29. () => props.overview.organizationShared || props.overview.outOfOffice,
  30. )
  31. const tooltipMessages = computed(() => {
  32. const messages: TooltipItemDescriptor[] = []
  33. if (props.overview.organizationShared)
  34. messages.push({
  35. type: 'text',
  36. label: __(
  37. 'This overview is visible only when you are a shared organization member.',
  38. ),
  39. })
  40. if (props.overview.outOfOffice)
  41. messages.push({
  42. type: 'text',
  43. label: __(
  44. 'This overview is visible only when you are an out of office replacement.',
  45. ),
  46. })
  47. return messages
  48. })
  49. </script>
  50. <template>
  51. <div
  52. class="flex min-h-[54px] cursor-move items-center gap-2 border-b border-gray-300 p-3 last:border-0"
  53. data-test-id="overviewItem"
  54. :draggable="draggable ? 'true' : undefined"
  55. >
  56. <div
  57. class="shrink-0 cursor-pointer items-center justify-center"
  58. :class="icon.class"
  59. role="button"
  60. tabindex="0"
  61. @keydown.enter="emit('action')"
  62. @click="emit('action')"
  63. @mousedown="emit('action-active', true)"
  64. @mouseup="emit('action-active', false)"
  65. @mouseout="emit('action-active', false)"
  66. @focusout="emit('action-active', false)"
  67. @blur="emit('action-active', false)"
  68. @touchstart="emit('action-active', true)"
  69. @touchend="emit('action-active', false)"
  70. @touchcancel="emit('action-active', false)"
  71. >
  72. <CommonIcon :name="icon.name" size="base" />
  73. </div>
  74. <div class="flex flex-1 items-center gap-2">
  75. <span class="truncate">{{ $t(overview.name) }}</span>
  76. <CommonTooltip
  77. v-if="hasTooltip"
  78. class="shrink-0"
  79. name="visibility"
  80. :messages="tooltipMessages"
  81. :heading="__('Limited Visibility')"
  82. >
  83. <CommonIcon name="tooltip" size="small" />
  84. </CommonTooltip>
  85. </div>
  86. <CommonIcon
  87. v-if="draggable"
  88. name="change-order"
  89. size="small"
  90. class="text-gray shrink-0"
  91. />
  92. </div>
  93. </template>