diff --git a/app/Http/Controllers/Forms/RecordController.php b/app/Http/Controllers/Forms/RecordController.php new file mode 100644 index 0000000..2a20910 --- /dev/null +++ b/app/Http/Controllers/Forms/RecordController.php @@ -0,0 +1,24 @@ +authorize('delete', $form); + + $record = $form->submissions()->where('id', $recordId)->firstOrFail(); + $record->delete(); + + return $this->success([ + 'message' => 'Record successfully removed.' + ]); + } + +} diff --git a/app/Http/Resources/FormSubmissionResource.php b/app/Http/Resources/FormSubmissionResource.php index 9c59516..e500dd1 100644 --- a/app/Http/Resources/FormSubmissionResource.php +++ b/app/Http/Resources/FormSubmissionResource.php @@ -16,7 +16,7 @@ class FormSubmissionResource extends JsonResource public function toArray($request) { $this->generateFileLinks(); - $this->addTimestamp(); + $this->addExtraData(); return [ 'data' => $this->data, @@ -25,10 +25,11 @@ class FormSubmissionResource extends JsonResource ]; } - private function addTimestamp() + private function addExtraData() { $this->data = array_merge($this->data, [ - "created_at" => $this->created_at->toDateTimeString() + "created_at" => $this->created_at->toDateTimeString(), + 'id' => $this->id ]); } diff --git a/app/Service/OpenAi/Utils/JsonFixer.php b/app/Service/OpenAi/Utils/JsonFixer.php index f65cfa8..aa54557 100644 --- a/app/Service/OpenAi/Utils/JsonFixer.php +++ b/app/Service/OpenAi/Utils/JsonFixer.php @@ -11,7 +11,7 @@ namespace App\Service\OpenAi\Utils; * Licensed under MIT license. */ -use App\Exceptions\Coursework\InvalidJsonException; +use Aws\Exception\InvalidJsonException; /** * Attempts to fix truncated JSON by padding contextual counterparts at the end. diff --git a/resources/js/components/open/components/RecordOperations.vue b/resources/js/components/open/components/RecordOperations.vue new file mode 100644 index 0000000..11de349 --- /dev/null +++ b/resources/js/components/open/components/RecordOperations.vue @@ -0,0 +1,65 @@ + + + diff --git a/resources/js/components/open/forms/components/FormSubmissions.vue b/resources/js/components/open/forms/components/FormSubmissions.vue index 11a7937..72901b0 100644 --- a/resources/js/components/open/forms/components/FormSubmissions.vue +++ b/resources/js/components/open/forms/components/FormSubmissions.vue @@ -53,6 +53,7 @@ :data="tableData" :loading="isLoading" @resize="dataChanged()" + @deleted="onDeleteRecord()" > @@ -186,6 +187,11 @@ export default { return this.displayColumns[field.id] === true }) this.$set(this.form, 'properties', final_properties) + }, + onDeleteRecord() { + this.fullyLoaded = false + this.tableData = [] + this.getSubmissionsData() } }, } diff --git a/resources/js/components/open/tables/OpenTable.vue b/resources/js/components/open/tables/OpenTable.vue index 35082dd..dfb4255 100644 --- a/resources/js/components/open/tables/OpenTable.vue +++ b/resources/js/components/open/tables/OpenTable.vue @@ -20,7 +20,7 @@ {{ col.name }}

- +

Actions @@ -39,7 +39,7 @@ - + + + + @@ -79,6 +84,7 @@ import OpenDate from './components/OpenDate.vue' import OpenFile from './components/OpenFile.vue' import OpenCheckbox from './components/OpenCheckbox.vue' import ResizableTh from './components/ResizableTh.vue' +import RecordOperations from '../components/RecordOperations.vue' import clonedeep from 'clone-deep' const cyrb53 = function (str, seed = 0) { @@ -95,7 +101,7 @@ const cyrb53 = function (str, seed = 0) { } export default { - components: {ResizableTh}, + components: {ResizableTh, RecordOperations}, props: { data: { type: Array, @@ -129,7 +135,8 @@ export default { } }, hasActions() { - return false + // In future if want to hide based on condition + return true }, fieldComponents() { return { diff --git a/resources/js/pages/forms/show/index.vue b/resources/js/pages/forms/show/index.vue index c80925a..5d970c8 100644 --- a/resources/js/pages/forms/show/index.vue +++ b/resources/js/pages/forms/show/index.vue @@ -13,13 +13,13 @@ Go back -

+

{{ form.title }}

- +
- + + - Draft (not public) + - Closed + - Edited {{ form.last_edited_human }} +

This form stopped accepting submissions on the {{ @@ -208,7 +208,7 @@ export default { this.workingForm = new Form(this.form) } }, - + methods: { openCrisp() { window.$crisp.push(['do', 'chat:show']) diff --git a/routes/api.php b/routes/api.php index 29257b1..e588568 100644 --- a/routes/api.php +++ b/routes/api.php @@ -14,6 +14,7 @@ use App\Http\Controllers\Forms\FormStatsController; use App\Http\Controllers\Forms\PublicFormController; use App\Http\Controllers\Forms\FormSubmissionController; use App\Http\Controllers\Forms\FormController; +use App\Http\Controllers\Forms\RecordController; use App\Http\Controllers\WorkspaceController; use App\Http\Controllers\TemplateController; use App\Http\Controllers\Forms\Integration\FormZapierWebhookController; @@ -83,6 +84,9 @@ Route::group(['middleware' => 'auth:api'], function () { Route::get('/{id}/submissions', [FormSubmissionController::class, 'submissions'])->name('submissions'); Route::get('/{id}/submissions/export', [FormSubmissionController::class, 'export'])->name('submissions.export'); Route::get('/{id}/submissions/file/{filename}', [FormSubmissionController::class, 'submissionFile'])->name('submissions.file'); + + Route::delete('/{id}/records/{recordid}/delete', [RecordController::class, 'delete'])->name('records.delete'); + // Form Admin tool Route::put('/{id}/regenerate-link/{option}', [FormController::class, 'regenerateLink'])