CommonUsersList.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import CommonUserAvatar from '#shared/components/CommonUserAvatar/CommonUserAvatar.vue'
  4. import type {
  5. AvatarUser,
  6. AvatarUserAccess,
  7. } from '#shared/components/CommonUserAvatar/types.ts'
  8. import { useAvatarIndicator } from '#shared/composables/useAvatarIndicator.ts'
  9. interface Props {
  10. users: (AvatarUser & { internalId: number })[]
  11. accessLookup?: Record<string, { access: AvatarUserAccess }>
  12. }
  13. const props = defineProps<Props>()
  14. const getAvatarIndicator = (user: AvatarUser) => {
  15. return useAvatarIndicator(
  16. user,
  17. false,
  18. undefined,
  19. props.accessLookup?.[user.id].access,
  20. )
  21. }
  22. </script>
  23. <template>
  24. <CommonLink
  25. v-for="user of users"
  26. :key="user.id"
  27. :link="`/users/${user.internalId}`"
  28. class="flex h-14 items-center px-3"
  29. >
  30. <div class="flex grow items-center">
  31. <CommonUserAvatar
  32. class="ltr:mr-3 rtl:ml-3"
  33. :entity="user"
  34. :access="accessLookup?.[user.id].access"
  35. decorative
  36. />
  37. <span class="truncate">
  38. {{ user.fullname }}
  39. </span>
  40. </div>
  41. <div
  42. v-if="getAvatarIndicator(user).indicatorIcon"
  43. class="flex items-center"
  44. >
  45. <CommonIcon
  46. :class="{ 'fill-gray': getAvatarIndicator(user).indicatorIsIdle.value }"
  47. :label="getAvatarIndicator(user).indicatorLabel.value"
  48. :name="getAvatarIndicator(user).indicatorIcon.value || ''"
  49. />
  50. </div>
  51. </CommonLink>
  52. </template>