FieldTicketWrapper.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { markRaw } from 'vue'
  4. import type { FormFieldContext } from '#shared/components/Form/types/field.ts'
  5. import { AutocompleteSearchTicketDocument } from '#shared/entities/ticket/graphql/queries/autocompleteSearchTicket.api.ts'
  6. import { useApplicationStore } from '#shared/stores/application.ts'
  7. import FieldAutoCompleteInput from '../FieldAutoComplete/FieldAutoCompleteInput.vue'
  8. import FieldTicketOptionIcon from './FieldTicketOptionIcon.vue'
  9. import type { AutoCompleteTicketOption } from './types'
  10. import type { AutoCompleteProps } from '../FieldAutoComplete/types.ts'
  11. interface Props {
  12. context: FormFieldContext<
  13. AutoCompleteProps & {
  14. options?: AutoCompleteTicketOption[]
  15. exceptTicketInternalId?: number
  16. }
  17. >
  18. }
  19. const props = defineProps<Props>()
  20. const { config } = useApplicationStore()
  21. Object.assign(props.context, {
  22. optionIconComponent: markRaw(FieldTicketOptionIcon),
  23. gqlQuery: AutocompleteSearchTicketDocument,
  24. additionalQueryParams: {
  25. exceptTicketInternalId: props.context.exceptTicketInternalId,
  26. },
  27. filterInputPlaceholder: __('Ticket number or title'),
  28. // Currently it seems to be the search finds not the ticket with the complete ticket hook and number (e.g. Ticket#123456).
  29. stripFilter: (filter: string) => filter.replace(config.ticket_hook, ''),
  30. })
  31. </script>
  32. <template>
  33. <FieldAutoCompleteInput :context="context" v-bind="$attrs" />
  34. </template>