Beautiful Open-Source Form Builder
Add status column for partial submissions in FormExportService and update tests
Julien Nahum8d9544e802be
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..6b90289a0 100644--- a/api/tests/Feature/Forms/FormSubmissionExportTest.php+++ b/api/tests/Feature/Forms/FormSubmissionExportTest.php@@ -91,3 +91,102 @@ 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,+ 'properties' => [+ [+ 'id' => 'name_field',+ 'name' => 'Name',+ 'type' => 'text',+ 'required' => true,+ ],+ [+ 'id' => 'email_field',+ 'name' => 'Email',+ 'type' => 'email',+ 'required' => true,+ ]+ ]+ ]);++ // Create a partial submission (In Progress)+ $partialSubmissionData = $this->generateFormSubmissionData($form, [+ 'name_field' => 'John Partial',+ ]);+ $partialSubmissionData['is_partial'] = true;+ $this->postJson(route('forms.answer', $form->slug), $partialSubmissionData);++ // Create a completed submission+ $completedSubmissionData = $this->generateFormSubmissionData($form, [+ 'name_field' => 'Jane Complete',+ 'email_field' => '[email protected]'+ ]);+ $this->postJson(route('forms.answer', $form->slug), $completedSubmissionData);++ // Export with selected columns+ $response = $this->postJson(route('open.forms.submissions.export', [+ 'form' => $form,+ 'columns' => [+ 'name_field' => true,+ 'email_field' => true,+ ]+ ]));++ $response->assertSuccessful()+ ->assertHeader('content-disposition', 'attachment; filename=' . $form->slug . '-submission-data.csv');++ // Verify the exported CSV contains status column and correct values+ $content = $response->getContent();+ $lines = explode("\n", $content);++ // Check that CSV has at least 3 lines (header + 2 data rows)+ expect(count($lines))->toBeGreaterThanOrEqual(3);++ // Check header contains 'status'+ $headerLine = trim($lines[0]);+ expect($headerLine)->toContain('status');++ // Check that data rows contain 'In Progress' or 'Completed'+ $dataContent = implode("\n", array_slice($lines, 1));+ expect(str_contains($dataContent, 'In Progress') || str_contains($dataContent, '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,+ 'properties' => [+ [+ 'id' => 'name_field',+ 'name' => 'Name',+ 'type' => 'text',+ 'required' => true,+ ]+ ]+ ]);++ // Create a submission+ $submissionData = $this->generateFormSubmissionData($form, [+ 'name_field' => 'John Doe',+ ]);+ $this->postJson(route('forms.answer', $form->slug), $submissionData);++ // Export with selected columns+ $response = $this->postJson(route('open.forms.submissions.export', [+ 'form' => $form,+ 'columns' => [+ 'name_field' => true,+ ]+ ]));++ $response->assertSuccessful();++ // Verify the exported CSV does not contain status column+ $content = $response->getContent();+ 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}}