TicketSidebarOrganizationContent.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script lang="ts" setup>
  3. import type { AvatarOrganization } from '#shared/components/CommonOrganizationAvatar'
  4. import CommonOrganizationAvatar from '#shared/components/CommonOrganizationAvatar/CommonOrganizationAvatar.vue'
  5. import ObjectAttributes from '#shared/components/ObjectAttributes/ObjectAttributes.vue'
  6. import type { ObjectAttribute } from '#shared/entities/object-attributes/types/store.ts'
  7. import type { OrganizationQuery, User } from '#shared/graphql/types.ts'
  8. import type { ObjectLike } from '#shared/types/utils.ts'
  9. import { normalizeEdges } from '#shared/utils/helpers.ts'
  10. import type { MenuItem } from '#desktop/components/CommonPopoverMenu/types.ts'
  11. import CommonSimpleEntityList from '#desktop/components/CommonSimpleEntityList/CommonSimpleEntityList.vue'
  12. import { EntityType } from '#desktop/components/CommonSimpleEntityList/types.ts'
  13. import type { TicketSidebarContentProps } from '#desktop/pages/ticket/types/sidebar.ts'
  14. import TicketSidebarContent from '../TicketSidebarContent.vue'
  15. interface Props extends TicketSidebarContentProps {
  16. organization: OrganizationQuery['organization']
  17. organizationMembers: ReturnType<typeof normalizeEdges<Partial<User>>>
  18. objectAttributes: ObjectAttribute[]
  19. }
  20. defineProps<Props>()
  21. const persistentStates = defineModel<ObjectLike>({ required: true })
  22. defineEmits<{
  23. 'load-more-members': []
  24. }>()
  25. const actions: MenuItem[] = [
  26. {
  27. key: 'edit-organization',
  28. label: __('Edit Organization'),
  29. icon: 'organization-edit',
  30. show: (entity) => entity?.policy.update,
  31. onClick: (id) => {
  32. console.log(id, 'Edit organization')
  33. },
  34. },
  35. ]
  36. </script>
  37. <template>
  38. <TicketSidebarContent
  39. v-model="persistentStates.scrollPosition"
  40. :title="sidebarPlugin.title"
  41. :icon="sidebarPlugin.icon"
  42. :entity="organization"
  43. :actions="actions"
  44. >
  45. <CommonLink
  46. :link="`/organizations/${organization.internalId}`"
  47. class="flex gap-2"
  48. >
  49. <CommonOrganizationAvatar
  50. class="p-3.5"
  51. :entity="organization as AvatarOrganization"
  52. size="normal"
  53. />
  54. <CommonLabel size="large" class="dark:text-white"
  55. >{{ organization.name }}
  56. </CommonLabel>
  57. </CommonLink>
  58. <ObjectAttributes
  59. :object="organization"
  60. :attributes="objectAttributes"
  61. :skip-attributes="['name', 'vip', 'active']"
  62. />
  63. <CommonSimpleEntityList
  64. id="organization-members"
  65. v-model="persistentStates.collapseMembers"
  66. :type="EntityType.User"
  67. :label="__('Members')"
  68. :entity="organizationMembers"
  69. @load-more="$emit('load-more-members')"
  70. />
  71. </TicketSidebarContent>
  72. </template>