OrganizationDetailView.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 type { AvatarOrganization } from '#shared/components/CommonOrganizationAvatar/index.ts'
  6. import ObjectAttributes from '#shared/components/ObjectAttributes/ObjectAttributes.vue'
  7. import { useOnlineNotificationSeen } from '#shared/composables/useOnlineNotificationSeen.ts'
  8. import { useOrganizationDetail } from '#shared/entities/organization/composables/useOrganizationDetail.ts'
  9. import { useErrorHandler } from '#shared/errors/useErrorHandler.ts'
  10. import CommonLoader from '#mobile/components/CommonLoader/CommonLoader.vue'
  11. import CommonTicketStateList from '#mobile/components/CommonTicketStateList/CommonTicketStateList.vue'
  12. import OrganizationMembersList from '#mobile/components/Organization/OrganizationMembersList.vue'
  13. import { useHeader } from '#mobile/composables/useHeader.ts'
  14. import { useOrganizationEdit } from '#mobile/entities/organization/composables/useOrganizationEdit.ts'
  15. import { useOrganizationTicketsCount } from '#mobile/entities/organization/composables/useOrganizationTicketsCount.ts'
  16. interface Props {
  17. internalId: number
  18. }
  19. const props = defineProps<Props>()
  20. const { createQueryErrorHandler } = useErrorHandler()
  21. const errorCallback = createQueryErrorHandler({
  22. notFound: __(
  23. 'Organization with specified ID was not found. Try checking the URL for errors.',
  24. ),
  25. forbidden: __('You have insufficient rights to view this organization.'),
  26. })
  27. const {
  28. organization,
  29. loading,
  30. objectAttributes,
  31. organizationQuery,
  32. loadAllMembers,
  33. // loadOrganization,
  34. } = useOrganizationDetail(toRef(props, 'internalId'), errorCallback)
  35. // loadOrganization(props.internalId)
  36. useOnlineNotificationSeen(organization)
  37. const { openEditOrganizationDialog } = useOrganizationEdit()
  38. useHeader({
  39. title: __('Organization'),
  40. backUrl: '/',
  41. actionTitle: __('Edit'),
  42. actionHidden: computed(
  43. () => organization.value == null || !organization.value.policy.update,
  44. ),
  45. refetch: computed(
  46. () => organization.value != null && organizationQuery.loading().value,
  47. ),
  48. onAction() {
  49. if (!organization.value || !organization.value.policy.update) return
  50. openEditOrganizationDialog(organization.value)
  51. },
  52. })
  53. const { getTicketData } = useOrganizationTicketsCount()
  54. const ticketData = computed(() => getTicketData(organization.value))
  55. </script>
  56. <template>
  57. <div v-if="organization" class="px-4">
  58. <div class="flex flex-col items-center justify-center py-6">
  59. <div>
  60. <CommonOrganizationAvatar
  61. :entity="organization as AvatarOrganization"
  62. size="xl"
  63. />
  64. </div>
  65. <div class="mt-2 text-xl font-bold">
  66. {{ organization.name }}
  67. </div>
  68. </div>
  69. <ObjectAttributes
  70. :object="organization"
  71. :attributes="objectAttributes"
  72. :skip-attributes="['name']"
  73. />
  74. <OrganizationMembersList
  75. :organization="organization"
  76. :disable-show-more="loading"
  77. @load-more="loadAllMembers()"
  78. />
  79. <CommonTicketStateList
  80. v-if="ticketData"
  81. :create-link="ticketData.createLink"
  82. :create-label="ticketData.createLabel"
  83. :counts="ticketData.count"
  84. :tickets-link-query="ticketData.query"
  85. />
  86. </div>
  87. <CommonLoader v-else-if="loading" class="w-full p-4" :loading="loading" />
  88. </template>