TicketOverviewEditItem.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { TicketOverview } from '#mobile/entities/ticket/stores/ticketOverviews.ts'
  5. const props = defineProps<{
  6. action: 'add' | 'delete'
  7. draggable?: boolean
  8. overview: TicketOverview
  9. }>()
  10. const emit = defineEmits<{
  11. action: []
  12. 'action-active': [boolean]
  13. }>()
  14. const icon = computed(() => {
  15. if (props.action === 'add') {
  16. return {
  17. name: 'plus',
  18. class: 'text-green',
  19. }
  20. }
  21. return {
  22. name: 'minus',
  23. class: 'text-red',
  24. }
  25. })
  26. </script>
  27. <template>
  28. <div
  29. class="flex min-h-[54px] cursor-move items-center border-b border-gray-300 last:border-0"
  30. data-test-id="overviewItem"
  31. :draggable="draggable ? 'true' : undefined"
  32. >
  33. <div
  34. class="ms-3 shrink-0 cursor-pointer items-center justify-center ltr:mr-2 rtl:ml-2"
  35. :class="icon.class"
  36. role="button"
  37. tabindex="0"
  38. @keydown.enter="emit('action')"
  39. @click="emit('action')"
  40. @mousedown="emit('action-active', true)"
  41. @mouseup="emit('action-active', false)"
  42. @mouseout="emit('action-active', false)"
  43. @focusout="emit('action-active', false)"
  44. @blur="emit('action-active', false)"
  45. @touchstart="emit('action-active', true)"
  46. @touchend="emit('action-active', false)"
  47. @touchcancel="emit('action-active', false)"
  48. >
  49. <CommonIcon :name="icon.name" size="base" />
  50. </div>
  51. <div class="flex-1">
  52. {{ $t(overview.name) }}
  53. </div>
  54. <CommonIcon
  55. v-if="draggable"
  56. name="change-order"
  57. size="small"
  58. class="text-gray shrink-0 ltr:mr-4 rtl:ml-4"
  59. />
  60. </div>
  61. </template>