From b86b2b6063b635e1fea23275e2ba590173af16ac Mon Sep 17 00:00:00 2001 From: philipp lang Date: Mon, 19 Feb 2024 02:32:46 +0100 Subject: [PATCH] Add for_members field for sections --- app/Form/Fields/Field.php | 1 + resources/js/views/formtemplate/FormBuilder.vue | 8 ++++++++ tests/Feature/Form/FormStoreActionTest.php | 3 ++- tests/Feature/Form/FormtemplateIndexActionTest.php | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Form/Fields/Field.php b/app/Form/Fields/Field.php index 219b2fe5..c478cfd6 100644 --- a/app/Form/Fields/Field.php +++ b/app/Form/Fields/Field.php @@ -139,6 +139,7 @@ abstract class Field extends Data 'default' => static::default(), 'required' => false, 'nami_type' => null, + 'for_members' => true, ...collect(static::meta())->mapWithKeys(fn ($meta) => [$meta['key'] => $meta['default']])->toArray(), ], ]; diff --git a/resources/js/views/formtemplate/FormBuilder.vue b/resources/js/views/formtemplate/FormBuilder.vue index 9f4b929a..0db8f46f 100644 --- a/resources/js/views/formtemplate/FormBuilder.vue +++ b/resources/js/views/formtemplate/FormBuilder.vue @@ -23,6 +23,14 @@ + diff --git a/tests/Feature/Form/FormStoreActionTest.php b/tests/Feature/Form/FormStoreActionTest.php index 63153f42..839b20ff 100644 --- a/tests/Feature/Form/FormStoreActionTest.php +++ b/tests/Feature/Form/FormStoreActionTest.php @@ -36,7 +36,7 @@ class FormStoreActionTest extends FormTestCase ->mailTop('Guten Tag') ->mailBottom('Viele Grüße') ->headerImage('htzz.jpg') - ->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)])]) + ->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)])]) ->fake(); $this->postJson(route('form.store'))->assertOk(); @@ -53,6 +53,7 @@ class FormStoreActionTest extends FormTestCase $this->assertEquals('2023-07-07', $form->from->format('Y-m-d')); $this->assertEquals('2023-07-08', $form->to->format('Y-m-d')); $this->assertEquals('Geburtstag', $form->config['sections'][0]['fields'][0]['nami_type']); + $this->assertFalse($form->config['sections'][0]['fields'][0]['for_members']); $this->assertCount(1, $form->getMedia('headerImage')); $this->assertEquals('formname.jpg', $form->getMedia('headerImage')->first()->file_name); Event::assertDispatched(Succeeded::class, fn (Succeeded $event) => $event->message === 'Veranstaltung gespeichert.'); diff --git a/tests/Feature/Form/FormtemplateIndexActionTest.php b/tests/Feature/Form/FormtemplateIndexActionTest.php index e20e01d8..856ef0e2 100644 --- a/tests/Feature/Form/FormtemplateIndexActionTest.php +++ b/tests/Feature/Form/FormtemplateIndexActionTest.php @@ -39,6 +39,7 @@ class FormtemplateIndexActionTest extends TestCase 'default' => null, 'required' => false, 'nami_type' => null, + 'for_members' => true, 'options' => [], ] ]) @@ -52,6 +53,7 @@ class FormtemplateIndexActionTest extends TestCase 'default' => '', 'required' => false, 'nami_type' => null, + 'for_members' => true, ] ]) ->assertInertiaPath('data.meta.fields.8', [ @@ -64,6 +66,7 @@ class FormtemplateIndexActionTest extends TestCase 'default' => '', 'required' => false, 'nami_type' => null, + 'for_members' => true, 'rows' => 5, ] ])