Compare commits
3 Commits
0e69e7c7f1
...
43821ec416
Author | SHA1 | Date |
---|---|---|
|
43821ec416 | |
|
c3f58cebc6 | |
|
f05c85a035 |
|
@ -14,6 +14,9 @@ enum NamiType: string
|
|||
case REGION = 'Bezirk';
|
||||
case STAMM = 'Stamm';
|
||||
case EMAIL = 'E-Mail-Adresse';
|
||||
case ADDRESS = 'Adresse';
|
||||
case ZIP = 'PLZ';
|
||||
case LOCATION = 'Ort';
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, id: string}>
|
||||
|
@ -34,6 +37,9 @@ enum NamiType: string
|
|||
static::REGION => $this->matchRegion($member),
|
||||
static::STAMM => $this->matchGroup($member),
|
||||
static::EMAIL => $member->email,
|
||||
static::ADDRESS => $member->address,
|
||||
static::ZIP => $member->zip,
|
||||
static::LOCATION => $member->location,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -47,9 +53,8 @@ enum NamiType: string
|
|||
static::FIRSTNAME => $query->where('firstname', $value),
|
||||
static::LASTNAME => $query->where('lastname', $value),
|
||||
static::BIRTHDAY => $query->where('birthday', $value),
|
||||
static::REGION => $query,
|
||||
static::STAMM => $query,
|
||||
static::EMAIL => $query->where('email', $value),
|
||||
default => $query,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ abstract class Field extends Data
|
|||
public ColumnData $columns;
|
||||
public bool $forMembers;
|
||||
public ?SpecialType $specialType = null;
|
||||
public string $hint;
|
||||
|
||||
/** @var mixed */
|
||||
public $value;
|
||||
|
@ -150,6 +151,7 @@ abstract class Field extends Data
|
|||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
'special_type' => null,
|
||||
'hint' => '',
|
||||
...collect(static::meta())->mapWithKeys(fn ($meta) => [$meta['key'] => $meta['default']])->toArray(),
|
||||
],
|
||||
];
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach (DB::table('forms')->get() as $event) {
|
||||
$config = json_decode($event->config);
|
||||
$config->sections = array_map(function ($section) {
|
||||
$section->fields = array_map(function ($field) {
|
||||
$field->hint = '';
|
||||
return $field;
|
||||
}, $section->fields);
|
||||
|
||||
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) {
|
||||
$section->fields = array_map(function ($field) {
|
||||
$field->hint = '';
|
||||
return $field;
|
||||
}, $section->fields);
|
||||
|
||||
return $section;
|
||||
}, $config->sections);
|
||||
DB::table('formtemplates')->where('id', $event->id)->update(['config' => json_encode($config)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
|
@ -1 +1 @@
|
|||
Subproject commit 2e232a95fd84f6dcca80abe4d2ed37e1fac7e352
|
||||
Subproject commit b59bc28f649879321da870d8861810a8570454b2
|
|
@ -24,6 +24,7 @@
|
|||
<component :is="fields[singleField.model.type]" v-model="singleField.model" :payload="inner.sections" :meta="props.meta"></component>
|
||||
<f-select id="nami_type" v-model="singleField.model.nami_type" :options="meta.namiTypes" label="NaMi-Feld" size="sm" name="nami_type"></f-select>
|
||||
<f-select id="special_type" v-model="singleField.model.special_type" :options="meta.specialTypes" label="Bedeutung" size="sm" name="special_type"></f-select>
|
||||
<f-textarea id="hint" v-model="singleField.model.hint" label="Hinweis" size="sm" name="hint"></f-textarea>
|
||||
<f-switch
|
||||
v-show="singleField.model.nami_type === null"
|
||||
id="for_members"
|
||||
|
|
|
@ -386,6 +386,24 @@ class FormRegisterActionTest extends FormTestCase
|
|||
'Muster'
|
||||
];
|
||||
|
||||
yield [
|
||||
['address' => 'Maxstr 5'],
|
||||
NamiType::ADDRESS,
|
||||
'Maxstr 5'
|
||||
];
|
||||
|
||||
yield [
|
||||
['zip' => 44444],
|
||||
NamiType::ZIP,
|
||||
'44444'
|
||||
];
|
||||
|
||||
yield [
|
||||
['location' => 'Hilden'],
|
||||
NamiType::LOCATION,
|
||||
'Hilden'
|
||||
];
|
||||
|
||||
yield [
|
||||
['birthday' => '2023-06-06'],
|
||||
NamiType::BIRTHDAY,
|
||||
|
|
|
@ -29,7 +29,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)->forMembers(false)])])
|
||||
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)->hint('hhh')])])
|
||||
->fake();
|
||||
|
||||
$this->postJson(route('form.store'))->assertOk();
|
||||
|
@ -46,6 +46,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->get(0)->fields->get(0)->namiType->value);
|
||||
$this->assertEquals('hhh', $form->config->sections->get(0)->fields->get(0)->hint);
|
||||
$this->assertFalse($form->config->sections->get(0)->fields->get(0)->forMembers);
|
||||
$this->assertCount(1, $form->getMedia('headerImage'));
|
||||
$this->assertEquals('formname.jpg', $form->getMedia('headerImage')->first()->file_name);
|
||||
|
|
|
@ -21,6 +21,7 @@ use App\Form\Enums\SpecialType;
|
|||
* @method self namiType(?NamiType $type)
|
||||
* @method self forMembers(bool $forMembers)
|
||||
* @method self specialType(SpecialType $specialType)
|
||||
* @method self hint(string $hint)
|
||||
*/
|
||||
class FormtemplateFieldRequest extends RequestFactory
|
||||
{
|
||||
|
@ -35,6 +36,7 @@ class FormtemplateFieldRequest extends RequestFactory
|
|||
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
||||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
'hint' => '',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ class FormtemplateIndexActionTest extends TestCase
|
|||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
'special_type' => null,
|
||||
'hint' => '',
|
||||
'options' => [],
|
||||
]
|
||||
])
|
||||
|
@ -57,6 +58,7 @@ class FormtemplateIndexActionTest extends TestCase
|
|||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
'special_type' => null,
|
||||
'hint' => '',
|
||||
]
|
||||
])
|
||||
->assertInertiaPath('data.meta.fields.8', [
|
||||
|
@ -71,6 +73,7 @@ class FormtemplateIndexActionTest extends TestCase
|
|||
'nami_type' => null,
|
||||
'for_members' => true,
|
||||
'special_type' => null,
|
||||
'hint' => '',
|
||||
'rows' => 5,
|
||||
]
|
||||
])
|
||||
|
|
|
@ -22,7 +22,7 @@ class FormtemplateStoreActionTest extends FormTestCase
|
|||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
FormtemplateRequest::new()->name('testname')->sections([
|
||||
FormtemplateSectionRequest::new()->name('Persönliches')->fields([
|
||||
$this->textField('a')->name('lala1')->columns(['mobile' => 2, 'tablet' => 2, 'desktop' => 1])->required(false),
|
||||
$this->textField('a')->name('lala1')->columns(['mobile' => 2, 'tablet' => 2, 'desktop' => 1])->required(false)->hint('hhh'),
|
||||
$this->textareaField('b')->name('lala2')->required(false)->specialType(SpecialType::FIRSTNAME)->rows(10),
|
||||
]),
|
||||
])->fake();
|
||||
|
@ -33,6 +33,7 @@ class FormtemplateStoreActionTest extends FormTestCase
|
|||
$this->assertEquals('Persönliches', $formtemplate->config->sections->get(0)->name);
|
||||
$this->assertEquals('lala1', $formtemplate->config->sections->get(0)->fields->get(0)->name);
|
||||
$this->assertNull($formtemplate->config->sections->get(0)->fields->get(0)->specialType);
|
||||
$this->assertEquals('hhh', $formtemplate->config->sections->get(0)->fields->get(0)->hint);
|
||||
$this->assertInstanceOf(TextField::class, $formtemplate->config->sections->get(0)->fields->get(0));
|
||||
$this->assertInstanceOf(TextareaField::class, $formtemplate->config->sections->get(0)->fields->get(1));
|
||||
$this->assertEquals(false, $formtemplate->config->sections->get(0)->fields->get(1)->required);
|
||||
|
|
Loading…
Reference in New Issue