OrganizationDetailView.vue 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. /* eslint-disable zammad/zammad-detect-translatable-string */
  4. import { useRouter } from 'vue-router'
  5. import { computed } from 'vue'
  6. import CommonOrganizationAvatar from '@shared/components/CommonOrganizationAvatar/CommonOrganizationAvatar.vue'
  7. import { useHeader } from '@mobile/composables/useHeader'
  8. import CommonLoader from '@mobile/components/CommonLoader/CommonLoader.vue'
  9. import CommonTicketStateList from '@mobile/components/CommonTicketStateList/CommonTicketStateList.vue'
  10. import { redirectToError } from '@mobile/router/error'
  11. import { ErrorStatusCodes } from '@shared/types/error'
  12. import { useOrganizationEdit } from '@mobile/entities/organization/composables/useOrganizationEdit'
  13. import OrganizationMembersList from '@mobile/components/Organization/OrganizationMembersList.vue'
  14. import { AvatarOrganization } from '@shared/components/CommonOrganizationAvatar'
  15. import ObjectAttributes from '@shared/components/ObjectAttributes/ObjectAttributes.vue'
  16. import { useOrganizationTicketsCount } from '@mobile/entities/organization/composables/useOrganizationTicketsCount'
  17. import { useOrganizationDetail } from '@mobile/entities/organization/composables/useOrganizationDetail'
  18. interface Props {
  19. internalId: number
  20. }
  21. const props = defineProps<Props>()
  22. const {
  23. organization,
  24. organizationQuery,
  25. loading,
  26. objectAttributes,
  27. loadAllMembers,
  28. loadOrganization,
  29. } = useOrganizationDetail()
  30. loadOrganization(props.internalId)
  31. const router = useRouter()
  32. organizationQuery.onError(() => {
  33. return redirectToError(router, {
  34. statusCode: ErrorStatusCodes.Forbidden,
  35. message: __('Sorry, but you have insufficient rights to open this page.'),
  36. })
  37. })
  38. const { openEditOrganizationDialog } = useOrganizationEdit()
  39. useHeader({
  40. title: __('Organization'),
  41. backUrl: '/',
  42. actionTitle: __('Edit'),
  43. onAction() {
  44. if (!organization.value) return
  45. openEditOrganizationDialog(organization.value)
  46. },
  47. })
  48. const { getTicketData } = useOrganizationTicketsCount()
  49. const ticketData = computed(() => getTicketData(organization.value))
  50. </script>
  51. <template>
  52. <div v-if="organization" class="px-4">
  53. <div class="flex flex-col items-center justify-center py-6">
  54. <div>
  55. <CommonOrganizationAvatar
  56. :entity="(organization as AvatarOrganization)"
  57. size="xl"
  58. personal
  59. />
  60. </div>
  61. <div class="mt-2 text-xl font-bold">
  62. {{ organization.name }}
  63. </div>
  64. </div>
  65. <ObjectAttributes
  66. :object="organization"
  67. :attributes="objectAttributes"
  68. :skip-attributes="['name']"
  69. />
  70. <OrganizationMembersList
  71. :organization="organization"
  72. :disable-show-more="loading"
  73. @load-more="loadAllMembers()"
  74. />
  75. <CommonTicketStateList
  76. v-if="ticketData"
  77. :create-link="ticketData.createLink"
  78. :create-label="ticketData.createLabel"
  79. :counts="ticketData.count"
  80. :tickets-link-query="ticketData.query"
  81. />
  82. </div>
  83. <CommonLoader v-else-if="loading" class="w-full p-4" :loading="loading" />
  84. </template>