|
4 | 4 | import { |
5 | 5 | FormAutocompleteItemData, |
6 | 6 | FormAutocompleteLocalFieldData, |
7 | | - FormAutocompleteRemoteFieldData, |
| 7 | + FormAutocompleteRemoteFieldData |
8 | 8 | } from "@/types"; |
9 | 9 | import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; |
10 | 10 | import { computed, ref } from "vue"; |
|
21 | 21 | import { route } from "@/utils/url"; |
22 | 22 | import { api } from "@/api/api"; |
23 | 23 | import { useParentForm } from "@/form/useParentForm"; |
24 | | - import { isCancel } from "axios"; |
25 | 24 | import { ComboboxItemIndicator } from "reka-ui"; |
26 | | - import { useParentCommands } from "@/commands/useCommands"; |
27 | 25 | import { useIsInDialog } from "@/components/ui/dialog/Dialog.vue"; |
28 | 26 | import { useFullTextSearch } from "@/composables/useFullTextSearch"; |
29 | 27 | import { useRemoteAutocomplete } from "@/composables/useRemoteAutocomplete"; |
| 28 | + import { useFieldContainerData } from "@/form/useFieldContainerData"; |
| 29 | + import { useParentListField } from "@/form/components/fields/list/useParentListField"; |
30 | 30 |
|
31 | 31 | const props = defineProps<FormFieldProps<FormAutocompleteLocalFieldData | FormAutocompleteRemoteFieldData>>(); |
32 | 32 | const emit = defineEmits<FormFieldEmits<FormAutocompleteLocalFieldData | FormAutocompleteRemoteFieldData>>(); |
|
36 | 36 | const searchTerm = ref(''); |
37 | 37 | const results = ref<FormAutocompleteItemData[]>([]); |
38 | 38 |
|
39 | | - const parentCommands = useParentCommands(); |
40 | 39 | const isInDialog = useIsInDialog(); |
41 | 40 | const { fullTextSearch } = useFullTextSearch( |
42 | 41 | () => props.field.mode === 'local' ? props.field.localValues : null, |
|
45 | 44 | searchKeys: props.field.mode === 'local' ? props.field.searchKeys : [], |
46 | 45 | } |
47 | 46 | ); |
| 47 | + const parentListField = useParentListField(); |
| 48 | + const fieldContainerData = useFieldContainerData(form); |
48 | 49 | const { loading, search: remoteSearch } = useRemoteAutocomplete(({ query, signal, onSuccess, onError }) => { |
49 | 50 | const field = props.field as FormAutocompleteRemoteFieldData; |
50 | 51 | return api.post( |
51 | 52 | route('code16.sharp.api.form.autocomplete.index', { |
52 | 53 | entityKey: form.entityKey, |
53 | | - autocompleteFieldKey: props.parentField ? `${props.parentField.key}.${field.key}` : field.key, |
54 | | - embed_key: form.embedKey, |
55 | | - entity_list_command_key: parentCommands?.commandContainer === 'entityList' ? form.commandKey : null, |
56 | | - show_command_key: parentCommands?.commandContainer === 'show' ? form.commandKey : null, |
57 | | - dashboard_command_key: parentCommands?.commandContainer === 'dashboard' ? form.commandKey : null, |
58 | | - instance_id: form.instanceId, |
| 54 | + autocompleteFieldKey: parentListField && parentListField.form === form |
| 55 | + ? `${parentListField.props.field.key}.${field.key}` |
| 56 | + : field.key, |
59 | 57 | endpoint: field.remoteEndpoint, |
60 | 58 | search: query, |
| 59 | + ...fieldContainerData, |
61 | 60 | }), { |
62 | 61 | formData: field.callbackLinkedFields |
63 | 62 | ? Object.fromEntries( |
|
0 commit comments