diff --git a/app/Form/Resources/ParticipantResource.php b/app/Form/Resources/ParticipantResource.php index ec3f3991..b5029e62 100644 --- a/app/Form/Resources/ParticipantResource.php +++ b/app/Form/Resources/ParticipantResource.php @@ -29,6 +29,7 @@ class ParticipantResource extends JsonResource 'children_count' => $this->children_count, 'links' => [ 'destroy' => route('participant.destroy', ['participant' => $this->getModel()]), + 'children' => route('form.participant.index', ['form' => $this->form, 'parent' => $this->id]) ] ]; } diff --git a/resources/js/composables/useApiIndex.js b/resources/js/composables/useApiIndex.js index 13a64dcc..ffba4997 100644 --- a/resources/js/composables/useApiIndex.js +++ b/resources/js/composables/useApiIndex.js @@ -2,10 +2,12 @@ import {ref, inject, onBeforeUnmount} from 'vue'; import {router} from '@inertiajs/vue3'; import useQueueEvents from './useQueueEvents.js'; -export function useApiIndex(url, siteName) { +export function useApiIndex(firstUrl, siteName) { const axios = inject('axios'); const {startListener, stopListener} = useQueueEvents(siteName, () => reload()); const single = ref(null); + + const url = ref(firstUrl); const inner = { data: ref([]), meta: ref({}), @@ -17,7 +19,7 @@ export function useApiIndex(url, siteName) { ...p, }; - var response = (await axios.get(url, {params})).data; + var response = (await axios.get(url.value, {params})).data; inner.data.value = response.data; inner.meta.value = response.meta; } @@ -72,6 +74,10 @@ export function useApiIndex(url, siteName) { single.value = null; } + function updateUrl(newUrl) { + url.value = newUrl; + } + startListener(); onBeforeUnmount(() => stopListener()); @@ -91,5 +97,7 @@ export function useApiIndex(url, siteName) { cancel, axios, toFilterString, + updateUrl, + url, }; } diff --git a/resources/js/views/form/Participants.vue b/resources/js/views/form/Participants.vue index 6b333f6c..29d9afaa 100644 --- a/resources/js/views/form/Participants.vue +++ b/resources/js/views/form/Participants.vue @@ -10,6 +10,7 @@ +