TicketViewersDialog.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { toRef } from 'vue'
  4. import { useTicketLiveUsersDisplay } from '#shared/entities/ticket/composables/useTicketLiveUsersDisplay.ts'
  5. import type { TicketLiveAppUser } from '#shared/entities/ticket/types.ts'
  6. import CommonDialog from '#mobile/components/CommonDialog/CommonDialog.vue'
  7. import CommonSectionMenu from '#mobile/components/CommonSectionMenu/CommonSectionMenu.vue'
  8. import TicketViewerItem from './TicketViewerItem.vue'
  9. interface Props {
  10. name: string
  11. liveUsers: TicketLiveAppUser[]
  12. }
  13. const props = defineProps<Props>()
  14. const { viewingUsers, idleUsers } = useTicketLiveUsersDisplay(
  15. toRef(() => props.liveUsers),
  16. )
  17. </script>
  18. <template>
  19. <CommonDialog
  20. :name="name"
  21. :label="__('Ticket viewers')"
  22. class="w-full p-4 text-sm"
  23. >
  24. <CommonSectionMenu
  25. v-if="viewingUsers.length > 0"
  26. class="shrink-0 gap-3 py-2"
  27. :header-label="__('Viewing ticket')"
  28. >
  29. <TicketViewerItem
  30. v-for="(viewingUser, index) in viewingUsers"
  31. :key="`${index}-${viewingUser.user.id}`"
  32. :user="viewingUser.user"
  33. :editing="viewingUser.editing"
  34. :app="viewingUser.app"
  35. />
  36. </CommonSectionMenu>
  37. <CommonSectionMenu
  38. v-if="idleUsers.length > 0"
  39. class="shrink-0 gap-3 py-2"
  40. :header-label="__('Opened in tabs')"
  41. :help="
  42. __(
  43. 'Has ticket open in tabs, but is not actively looking at the ticket.',
  44. )
  45. "
  46. >
  47. <TicketViewerItem
  48. v-for="(idleUser, index) in idleUsers"
  49. :key="`${index}-${idleUser.user.id}`"
  50. :user="idleUser.user"
  51. :editing="idleUser.editing"
  52. :app="idleUser.app"
  53. idle
  54. />
  55. </CommonSectionMenu>
  56. </CommonDialog>
  57. </template>