OrganizationItem.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 { useEditedBy } from '#mobile/composables/useEditedBy.ts'
  6. import type { OrganizationItemData } from './types.ts'
  7. export interface Props {
  8. entity: OrganizationItemData
  9. }
  10. const props = defineProps<Props>()
  11. const { stringUpdated } = useEditedBy(toRef(props, 'entity'))
  12. const users = computed(() => {
  13. const { members } = props.entity
  14. if (!members) return ''
  15. const users = members.edges
  16. .map((edge) => edge.node.fullname)
  17. .filter((fullname) => fullname && fullname !== '-')
  18. .slice(0, 2)
  19. let usersString = users.join(', ')
  20. const length = members.totalCount - users.length
  21. if (length > 0) {
  22. usersString += `, +${length}`
  23. }
  24. return usersString
  25. })
  26. </script>
  27. <template>
  28. <div class="flex ltr:pr-3 rtl:pl-3">
  29. <div class="mt-4 flex w-14 justify-center">
  30. <CommonOrganizationAvatar
  31. aria-hidden="true"
  32. class="bg-gray"
  33. :entity="entity"
  34. />
  35. </div>
  36. <div
  37. class="flex flex-1 flex-col overflow-hidden border-b border-white/10 py-3 text-gray-100"
  38. >
  39. <span class="truncate">
  40. {{
  41. entity.ticketsCount?.open === 1
  42. ? `1 ${$t('ticket')}`
  43. : $t('%s tickets', entity.ticketsCount?.open || 0)
  44. }}
  45. <template v-if="users">
  46. ·
  47. {{ users }}
  48. </template>
  49. </span>
  50. <span
  51. class="mb-1 line-clamp-3 whitespace-normal text-lg font-bold leading-5"
  52. >
  53. <slot> {{ entity.name }} </slot>
  54. </span>
  55. <div
  56. v-if="stringUpdated"
  57. data-test-id="stringUpdated"
  58. class="text-gray truncate"
  59. >
  60. {{ stringUpdated }}
  61. </div>
  62. </div>
  63. </div>
  64. </template>