OrganizationItem.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useEditedBy } from '@mobile/composables/useEditedBy'
  4. import CommonOrganizationAvatar from '@shared/components/CommonOrganizationAvatar/CommonOrganizationAvatar.vue'
  5. import { computed, toRef } from 'vue'
  6. import type { OrganizationItemData } from './types'
  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="overflow-hidden text-ellipsis whitespace-nowrap">
  40. <!-- TODO: Should we show open or closed or nothing at all? -->
  41. {{
  42. entity.ticketsCount?.open === 1
  43. ? `1 ${$t('ticket')}`
  44. : $t('%s tickets', entity.ticketsCount?.open || 0)
  45. }}
  46. <template v-if="users">
  47. ·
  48. {{ users }}
  49. </template>
  50. </span>
  51. <span
  52. class="mb-1 whitespace-normal text-lg font-bold leading-5 line-clamp-3"
  53. >
  54. <slot> {{ entity.name }} </slot>
  55. </span>
  56. <div
  57. v-if="stringUpdated"
  58. data-test-id="stringUpdated"
  59. class="overflow-hidden text-ellipsis text-gray"
  60. >
  61. {{ stringUpdated }}
  62. </div>
  63. </div>
  64. </div>
  65. </template>