Add for_members field for sections

This commit is contained in:
philipp lang 2024-02-19 02:32:46 +01:00
parent 94397165c6
commit b86b2b6063
4 changed files with 14 additions and 1 deletions

View File

@ -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(),
],
];

View File

@ -23,6 +23,14 @@
<column-selector v-model="singleField.model.columns"></column-selector>
<component :is="fields[singleField.model.type]" v-model="singleField.model" :payload="inner.sections" :meta="props.meta"></component>
<f-select id="nami_field" v-model="singleField.model.nami_field" :options="meta.namiFields" label="NaMi-Feld" size="sm" name="nami_field"></f-select>
<f-switch
v-show="singleField.model.nami_field === null"
id="for_members"
v-model="singleField.model.for_members"
label="Für Unter-Mitglieder zusätzlich abfragen"
size="sm"
name="for_members"
></f-switch>
</asideform>
</div>
<ui-box heading="Vorschau" container-class="grid gap-3" class="w-[800px]">

View File

@ -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.');

View File

@ -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,
]
])