ticket.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { useConfirmation } from '#shared/composables/useConfirmation.ts'
  3. import { TicketTaskbarTabAttributesFragmentDoc } from '#shared/entities/ticket/graphql/fragments/ticketTaskbarTabAttributes.api.ts'
  4. import {
  5. EnumTaskbarEntity,
  6. type Ticket as TicketType,
  7. } from '#shared/graphql/types.ts'
  8. import type { UserTaskbarTabPlugin } from '#desktop/components/UserTaskbarTabs/types.ts'
  9. import Ticket from '../Ticket/Ticket.vue'
  10. const entityType = 'Ticket'
  11. export default <UserTaskbarTabPlugin>{
  12. type: EnumTaskbarEntity.TicketZoom,
  13. component: Ticket,
  14. entityType,
  15. entityDocument: TicketTaskbarTabAttributesFragmentDoc,
  16. buildEntityTabKey: (entityInternalId: string) =>
  17. `${entityType}-${entityInternalId}`,
  18. buildTaskbarTabParams: (entityInternalId: string) => {
  19. return {
  20. ticket_id: entityInternalId,
  21. }
  22. },
  23. buildTaskbarTabLink: (entity?: TicketType, entityKey?: string) => {
  24. if (!entity?.internalId) {
  25. if (!entityKey) return
  26. return `/tickets/${entityKey.split('-')?.[1]}`
  27. }
  28. return `/tickets/${entity.internalId}`
  29. },
  30. confirmTabRemove: async (dirty?: boolean) => {
  31. if (!dirty) return true
  32. const { waitForVariantConfirmation } = useConfirmation()
  33. return waitForVariantConfirmation('unsaved')
  34. },
  35. }