TicketDetailView.vue 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, toRef, provide } from 'vue'
  4. import {
  5. useArticleDataHandler,
  6. type AddArticleCallbackArgs,
  7. } from '#shared/entities/ticket-article/composables/useArticleDataHandler.ts'
  8. import { EnumTaskbarEntity } from '#shared/graphql/types.ts'
  9. import { QueryHandler } from '#shared/server/apollo/handler/index.ts'
  10. import CommonLoader from '#desktop/components/CommonLoader/CommonLoader.vue'
  11. import LayoutContent from '#desktop/components/layout/LayoutContent.vue'
  12. import { useTaskbarTab } from '#desktop/entities/user/current/composables/useTaskbarTab.ts'
  13. import ArticleList from '../components/TicketDetailView/ArticleList.vue'
  14. import TicketDetailTopBar from '../components/TicketDetailView/TicketDetailTopBar/TicketDetailTopBar.vue'
  15. import TicketSidebar from '../components/TicketSidebar.vue'
  16. import { ARTICLES_INFORMATION_KEY } from '../composables/useArticleContext.ts'
  17. import {
  18. useProvideTicketInformation,
  19. useTicketInformation,
  20. } from '../composables/useTicketInformation.ts'
  21. import {
  22. useTicketSidebar,
  23. useProvideTicketSidebar,
  24. } from '../composables/useTicketSidebar.ts'
  25. import {
  26. type TicketSidebarContext,
  27. TicketSidebarScreenType,
  28. } from '../types/sidebar.ts'
  29. interface Props {
  30. internalId: string
  31. }
  32. const props = defineProps<Props>()
  33. useTaskbarTab(EnumTaskbarEntity.TicketZoom)
  34. useProvideTicketInformation(toRef(props, 'internalId'))
  35. const { ticket, ticketId } = useTicketInformation()
  36. const onAddArticleCallback = ({ articlesQuery }: AddArticleCallbackArgs) => {
  37. return (articlesQuery as QueryHandler).refetch()
  38. }
  39. const { articleResult, articlesQuery, isLoadingArticles } =
  40. useArticleDataHandler(ticketId, { pageSize: 20, onAddArticleCallback })
  41. provide(ARTICLES_INFORMATION_KEY, {
  42. articles: computed(() => articleResult.value),
  43. articlesQuery,
  44. })
  45. const sidebarContext = computed<TicketSidebarContext>(() => ({
  46. screenType: TicketSidebarScreenType.TicketDetailView,
  47. formValues: {
  48. // Workaround, to make the sidebars working for now.
  49. customer_id: ticket.value?.customer.internalId,
  50. organization_id: ticket.value?.organization?.internalId,
  51. },
  52. }))
  53. useProvideTicketSidebar(sidebarContext)
  54. const { hasSidebar } = useTicketSidebar()
  55. </script>
  56. <template>
  57. <LayoutContent
  58. name="ticket-detail"
  59. no-padding
  60. background-variant="primary"
  61. :show-sidebar="hasSidebar"
  62. hide-button-when-collapsed
  63. content-alignment="center"
  64. >
  65. <CommonLoader class="mt-8" :loading="!ticket">
  66. <div class="relative flex w-full flex-col">
  67. <TicketDetailTopBar />
  68. <ArticleList :aria-busy="isLoadingArticles" />
  69. <p>Tickt: <CommonLink link="/tickets/1">Testing 1</CommonLink></p>
  70. </div>
  71. </CommonLoader>
  72. <template #sideBar="{ isCollapsed, toggleCollapse }">
  73. <TicketSidebar
  74. :is-collapsed="isCollapsed"
  75. :toggle-collapse="toggleCollapse"
  76. :context="sidebarContext"
  77. />
  78. </template>
  79. </LayoutContent>
  80. </template>