From 7e152c017ab30a5e72d3013f340ef3f53c4fff5e Mon Sep 17 00:00:00 2001 From: philipp lang Date: Fri, 7 Jun 2024 00:48:54 +0200 Subject: [PATCH] Add intro to fields --- app/Form/Fields/Field.php | 1 + .../2024_06_07_003232_add_intro_field.php | 58 ++++++++++++ .../js/views/formtemplate/FormBuilder.vue | 88 ++++++++++--------- .../Form/FormtemplateStoreActionTest.php | 3 +- 4 files changed, 109 insertions(+), 41 deletions(-) create mode 100644 database/migrations/2024_06_07_003232_add_intro_field.php diff --git a/app/Form/Fields/Field.php b/app/Form/Fields/Field.php index 36f43f39..078fbc31 100644 --- a/app/Form/Fields/Field.php +++ b/app/Form/Fields/Field.php @@ -29,6 +29,7 @@ abstract class Field extends Data public bool $forMembers; public ?SpecialType $specialType = null; public ?string $hint; + public ?string $intro; /** @var mixed */ public $value; diff --git a/database/migrations/2024_06_07_003232_add_intro_field.php b/database/migrations/2024_06_07_003232_add_intro_field.php new file mode 100644 index 00000000..8b7f5cc8 --- /dev/null +++ b/database/migrations/2024_06_07_003232_add_intro_field.php @@ -0,0 +1,58 @@ +get() as $event) { + $config = json_decode($event->config); + $config->sections = array_map(function ($section) { + /** @var Collection */ + $fields = $section->fields; + $section->fields = collect($fields)->map(function ($field) { + $field->intro = null; + return $field; + })->all(); + + return $section; + }, $config->sections); + DB::table('forms')->where('id', $event->id)->update(['config' => json_encode($config)]); + } + + foreach (DB::table('formtemplates')->get() as $event) { + $config = json_decode($event->config); + $config->sections = array_map(function ($section) { + /** @var Collection */ + $fields = $section->fields; + $section->fields = collect($fields)->map(function ($field) { + $field->intro = null; + return $field; + })->all(); + + return $section; + }, $config->sections); + DB::table('formtemplates')->where('id', $event->id)->update(['config' => json_encode($config)]); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}; diff --git a/resources/js/views/formtemplate/FormBuilder.vue b/resources/js/views/formtemplate/FormBuilder.vue index f5698735..0eaea6d0 100644 --- a/resources/js/views/formtemplate/FormBuilder.vue +++ b/resources/js/views/formtemplate/FormBuilder.vue @@ -2,70 +2,78 @@
- - - + @close="singleSection = null" + @submit="storeSection" + > + + - - -