diff --git a/app/Http/Controllers/Forms/FormSubmissionController.php b/app/Http/Controllers/Forms/FormSubmissionController.php index 5c96bc9..ba7a8f8 100644 --- a/app/Http/Controllers/Forms/FormSubmissionController.php +++ b/app/Http/Controllers/Forms/FormSubmissionController.php @@ -35,7 +35,8 @@ class FormSubmissionController extends Controller foreach ($form->submissions->toArray() as $row) { $formatter = (new FormSubmissionFormatter($form, $row['data'])) ->outputStringsOnly() - ->setEmptyForNoValue(); + ->setEmptyForNoValue() + ->showRemovedFields(); $tmp = $formatter->getCleanKeyValue(); $tmp['Create Date'] = date("Y-m-d H:i", strtotime($row['created_at'])); $allRows[] = $tmp; diff --git a/app/Http/Resources/FormResource.php b/app/Http/Resources/FormResource.php index dbb850e..bad73e6 100644 --- a/app/Http/Resources/FormResource.php +++ b/app/Http/Resources/FormResource.php @@ -45,6 +45,7 @@ class FormResource extends JsonResource 'visibility' => $this->visibility, 'notification_emails' => $this->notification_emails, 'slack_webhook_url' => $this->slack_webhook_url, + 'removed_properties' => $this->removed_properties ] : []; $baseData = $this->getFilteredFormData(parent::toArray($request), $this->userIsFormOwner()); diff --git a/app/Service/Forms/FormSubmissionFormatter.php b/app/Service/Forms/FormSubmissionFormatter.php index 8ac7c5a..e4416d4 100644 --- a/app/Service/Forms/FormSubmissionFormatter.php +++ b/app/Service/Forms/FormSubmissionFormatter.php @@ -27,6 +27,8 @@ class FormSubmissionFormatter private $setEmptyForNoValue = false; + private $showRemovedFields = false; + public function __construct(private Form $form, private array $formData) { } @@ -55,6 +57,12 @@ class FormSubmissionFormatter return $this; } + public function showRemovedFields() + { + $this->showRemovedFields = true; + return $this; + } + /** * Return a nice "FieldName": "Field Response" array * - If createLink enabled, returns html link for emails and links @@ -63,10 +71,15 @@ class FormSubmissionFormatter public function getCleanKeyValue() { $data = $this->formData; - $fields = $this->form->properties; + $fields = ($this->showRemovedFields) ? array_merge($this->form->properties, $this->form->removed_properties) : $this->form->properties; $returnArray = []; foreach ($fields as &$field) { + $isRemoved = in_array($field['id'], array_column($this->form->removed_properties, 'id')) ?? false; + if($isRemoved){ + $field['name'] = $field['name']." (deleted)"; + } + // If not present skip if (!isset($data[$field['id']])) { if ($this->setEmptyForNoValue) { diff --git a/resources/js/components/forms/components/VSwitch.vue b/resources/js/components/forms/components/VSwitch.vue index 24da137..2be7471 100644 --- a/resources/js/components/forms/components/VSwitch.vue +++ b/resources/js/components/forms/components/VSwitch.vue @@ -1,42 +1,15 @@ - - + \ No newline at end of file diff --git a/resources/js/components/open/forms/components/FormSubmissions.vue b/resources/js/components/open/forms/components/FormSubmissions.vue index 5bb97ef..1d6bff0 100644 --- a/resources/js/components/open/forms/components/FormSubmissions.vue +++ b/resources/js/components/open/forms/components/FormSubmissions.vue @@ -2,11 +2,41 @@

- Form Submissions - - Export as CSV - + Form Submissions + - Export as CSV + Display columns

+ + + +
+
+

+ Display columns +

+
+
+ + +
+
+ Close +
+
+
+
!property.hasOwnProperty('hidden') || !property.hidden) - tmp.push({ - "name": "Create Date", - "id": "create_date", - "type": "date" - }); - return tmp - }, exportUrl() { if (!this.form) { return '' @@ -104,6 +127,20 @@ export default { }) this.$set(this.form, 'properties', columns) this.formInitDone = true + + this.properties = clonedeep(this.form.properties) + this.removed_properties = clonedeep(this.form.removed_properties) + + // Get display columns from local storage + const tmpColumns = window.localStorage.getItem('display-columns-formid-'+this.form.id) + if(tmpColumns !== null && tmpColumns){ + this.displayColumns = JSON.parse(tmpColumns) + this.onChangeDisplayColumns() + }else{ + this.form.properties.forEach((field) => { + this.displayColumns[field.id] = true + }) + } }, getSubmissionsData() { if (!this.form || this.fullyLoaded) { @@ -131,6 +168,13 @@ export default { this.$refs.shadows.toggleShadow() this.$refs.shadows.calcDimensions() }, + onChangeDisplayColumns(){ + window.localStorage.setItem('display-columns-formid-'+this.form.id, JSON.stringify(this.displayColumns)) + const final_properties = this.properties.concat(this.removed_properties).filter((field) => { + return this.displayColumns[field.id] === true + }) + this.$set(this.form, 'properties', final_properties) + } }, } diff --git a/tailwind.config.js b/tailwind.config.js index a36bd76..e1a00fd 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -40,6 +40,9 @@ module.exports = { 10: '10rem', 8: '2rem' }, + translate: { + 5.5: '1.4rem' + }, boxShadow: { 'inner-notion': '#0f0f0f1a 0px 0px 0px 1px inset', 'focus-notion': '#2eaadcb3 0px 0px 0px 1px inset, #2eaadc66 0px 0px 0px 2px !important'