Beautiful Open-Source Form Builder
Add status column for partial submissions in FormExportService and up… (#930)
Julien Nahumf011505849c7
diff --git a/api/app/Service/Forms/FormExportService.php b/api/app/Service/Forms/FormExportService.phpindex a9ee5a839..7cc64a152 100644--- a/api/app/Service/Forms/FormExportService.php+++ b/api/app/Service/Forms/FormExportService.php@@ -51,6 +51,11 @@ class FormExportService$filteredData['created_at'] = $submission->created_at->format('Y-m-d H:i');}+ // Add status column if partial submissions are enabled+ if ($form->enable_partial_submissions) {+ $filteredData['status'] = $submission->status === FormSubmission::STATUS_PARTIAL ? 'In Progress' : 'Completed';+ }+return $filteredData;}diff --git a/api/tests/Feature/Forms/FormSubmissionExportTest.php b/api/tests/Feature/Forms/FormSubmissionExportTest.phpindex 46bfc1111..993e1180a 100644--- a/api/tests/Feature/Forms/FormSubmissionExportTest.php+++ b/api/tests/Feature/Forms/FormSubmissionExportTest.php@@ -91,3 +91,87 @@ it('cannot export form submissions from another user form', function () {'message' => 'This action is unauthorized.']);});++it('includes status column when partial submissions are enabled', function () {+ $user = $this->actingAsProUser();+ $workspace = $this->createUserWorkspace($user);+ $form = $this->createForm($user, $workspace, [+ 'enable_partial_submissions' => true,+ ]);++ // Create a partial submission (In Progress)+ $textField = collect($form->properties)->firstWhere('type', 'text');+ $partialSubmissionData = $this->generateFormSubmissionData($form, [+ $textField['id'] => 'John Partial',+ ]);+ $partialSubmissionData['is_partial'] = true;+ $partialResponse = $this->postJson(route('forms.answer', $form->slug), $partialSubmissionData);+ $partialResponse->assertSuccessful();++ // Create a completed submission+ $emailField = collect($form->properties)->firstWhere('type', 'email');+ $completedSubmissionData = $this->generateFormSubmissionData($form, [+ $textField['id'] => 'Jane Complete',+ $emailField['id'] => '[email protected]'+ ]);+ $completedResponse = $this->postJson(route('forms.answer', $form->slug), $completedSubmissionData);+ $completedResponse->assertSuccessful();++ // Verify counts before export+ $form->refresh();+ $total = $form->submissions()->count();+ $partialCount = $form->submissions()->where('status', \App\Models\Forms\FormSubmission::STATUS_PARTIAL)->count();++ // Export with selected columns (use real field ids)+ $response = $this->postJson(route('open.forms.submissions.export', [+ 'form' => $form,+ 'columns' => [+ $textField['id'] => true,+ $emailField['id'] => true,+ ]+ ]));++ $response->assertSuccessful()+ ->assertHeader('content-disposition', 'attachment; filename=' . $form->slug . '-submission-data.csv');++ // Verify the exported CSV contains status column and correct values+ ob_start();+ $response->sendContent();+ $content = ob_get_clean();++ expect(str_contains($content, 'status'))->toBeTrue();+ expect(str_contains($content, 'In Progress'))->toBeTrue();+ expect(str_contains($content, 'Completed'))->toBeTrue();+});++it('does not include status column when partial submissions are disabled', function () {+ $user = $this->actingAsProUser();+ $workspace = $this->createUserWorkspace($user);+ $form = $this->createForm($user, $workspace, [+ 'enable_partial_submissions' => false,+ ]);++ // Create a submission+ $textField = collect($form->properties)->firstWhere('type', 'text');+ $submissionData = $this->generateFormSubmissionData($form, [+ $textField['id'] => 'John Doe',+ ]);+ $this->postJson(route('forms.answer', $form->slug), $submissionData);++ // Export with selected columns (use a real field id)+ $response = $this->postJson(route('open.forms.submissions.export', [+ 'form' => $form,+ 'columns' => [+ $textField['id'] => true,+ ]+ ]));++ $response->assertSuccessful();++ // Verify the exported CSV does not contain status column+ ob_start();+ $response->sendContent();+ $content = ob_get_clean();++ expect(str_contains($content, 'status'))->toBeFalse();+});diff --git a/client/components/open/forms/components/FormSubmissions.vue b/client/components/open/forms/components/FormSubmissions.vueindex 2a3cb834e..0371f05ce 100644--- a/client/components/open/forms/components/FormSubmissions.vue+++ b/client/components/open/forms/components/FormSubmissions.vue@@ -12,6 +12,7 @@@search="handleSearch"@filter="handleFilter"@page-change="handlePageChange"+ @refresh="handleRefresh"/><!-- Submissions Table Skeleton -->@@ -59,7 +60,8 @@ const {isFetching,setSearch,setStatus,- setPage+ setPage,+ refetch} = paginatedList(computed(() => props.form?.id))// Replace existing event handlers:@@ -77,4 +79,10 @@ const handlePageChange = (page) => {setPage(page)}+const handleRefresh = () => {+ // Refetch the data with current parameters (page, search, status)+ refetch()+}++</script>diff --git a/client/components/open/tables/OpenTable.vue b/client/components/open/tables/OpenTable.vueindex 1d3ec4401..909c54c17 100644--- a/client/components/open/tables/OpenTable.vue+++ b/client/components/open/tables/OpenTable.vue@@ -48,13 +48,26 @@:columns="columnVisibility"/>- <UButton- size="sm"- color="neutral"- variant="ghost"- :icon="isExpanded ? 'i-heroicons-arrows-pointing-in' : 'i-heroicons-arrows-pointing-out'"- @click="toggleExpanded"- />+ <UTooltip text="Refresh" arrow>+ <UButton+ size="sm"+ color="neutral"+ variant="ghost"+ icon="i-heroicons-arrow-path"+ :loading="loading"+ @click="$emit('refresh')"+ />+ </UTooltip>++ <UTooltip arrow :text="isExpanded ? 'Exit fullscreen' : 'Fullscreen'">+ <UButton+ size="sm"+ color="neutral"+ variant="ghost"+ :icon="isExpanded ? 'i-heroicons-arrows-pointing-in' : 'i-heroicons-arrows-pointing-out'"+ @click="toggleExpanded"+ />+ </UTooltip><!-- Add pagination section --><UPagination@@ -200,7 +213,7 @@ const props = defineProps({},})-const emit = defineEmits(["search", "filter", "page-change"])+const emit = defineEmits(["search", "filter", "page-change", "refresh"])// Get workspace for table stateconst { current: workspace } = useCurrentWorkspace()diff --git a/client/composables/query/forms/useFormSubmissions.js b/client/composables/query/forms/useFormSubmissions.jsindex 1dcead16c..323c5cf5c 100644--- a/client/composables/query/forms/useFormSubmissions.js+++ b/client/composables/query/forms/useFormSubmissions.js@@ -127,7 +127,8 @@ export function useFormSubmissions() {// ActionssetSearch,setStatus,- setPage+ setPage,+ refetch: query.refetch}}