Compare commits
No commits in common. "58bb5ec87fe88b351239217aa54b54c1ff4e7404" and "c62f8ec676256234b9fb9145a4c5ad4a2662a002" have entirely different histories.
58bb5ec87f
...
c62f8ec676
|
@ -12,7 +12,6 @@ class DropdownField extends Field
|
||||||
public bool $required;
|
public bool $required;
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
public array $options;
|
public array $options;
|
||||||
public bool $allowcustom;
|
|
||||||
|
|
||||||
public static function name(): string
|
public static function name(): string
|
||||||
{
|
{
|
||||||
|
@ -24,7 +23,6 @@ class DropdownField extends Field
|
||||||
return [
|
return [
|
||||||
['key' => 'options', 'default' => [], 'rules' => ['options' => 'present|array', 'options.*' => 'string'], 'label' => 'Optionen'],
|
['key' => 'options', 'default' => [], 'rules' => ['options' => 'present|array', 'options.*' => 'string'], 'label' => 'Optionen'],
|
||||||
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
|
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
|
||||||
['key' => 'allowcustom', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Eigene Option erlauben'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +36,6 @@ class DropdownField extends Field
|
||||||
return [
|
return [
|
||||||
'options' => $faker->words(4),
|
'options' => $faker->words(4),
|
||||||
'required' => $faker->boolean(),
|
'required' => $faker->boolean(),
|
||||||
'allowcustom' => $faker->boolean(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,14 +44,8 @@ class DropdownField extends Field
|
||||||
*/
|
*/
|
||||||
public function getRegistrationRules(Form $form): array
|
public function getRegistrationRules(Form $form): array
|
||||||
{
|
{
|
||||||
$rules = $this->required ? ['required', 'string'] : ['nullable', 'string'];
|
|
||||||
|
|
||||||
if (!$this->allowcustom) {
|
|
||||||
$rules[] = Rule::in($this->options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$this->key => $rules
|
$this->key => $this->required ? ['required', 'string', Rule::in($this->options)] : ['nullable', 'string', Rule::in($this->options)],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Form\Fields;
|
||||||
|
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
|
use App\Form\Presenters\Presenter;
|
||||||
use Faker\Generator;
|
use Faker\Generator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
@ -12,7 +13,6 @@ class RadioField extends Field
|
||||||
public bool $required;
|
public bool $required;
|
||||||
/** @var array<int, string> */
|
/** @var array<int, string> */
|
||||||
public array $options;
|
public array $options;
|
||||||
public bool $allowcustom;
|
|
||||||
|
|
||||||
public static function name(): string
|
public static function name(): string
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,6 @@ class RadioField extends Field
|
||||||
return [
|
return [
|
||||||
['key' => 'options', 'default' => [], 'rules' => ['options' => 'present|array', 'options.*' => 'required|string'], 'label' => 'Optionen'],
|
['key' => 'options', 'default' => [], 'rules' => ['options' => 'present|array', 'options.*' => 'required|string'], 'label' => 'Optionen'],
|
||||||
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
|
['key' => 'required', 'default' => true, 'rules' => ['required' => 'present|boolean'], 'label' => 'Erforderlich'],
|
||||||
['key' => 'allowcustom', 'default' => false, 'rules' => ['required' => 'present|boolean'], 'label' => 'Eigene Option erlauben'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +37,6 @@ class RadioField extends Field
|
||||||
return [
|
return [
|
||||||
'options' => $faker->words(4),
|
'options' => $faker->words(4),
|
||||||
'required' => $faker->boolean(),
|
'required' => $faker->boolean(),
|
||||||
'allowcustom' => $faker->boolean(),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,14 +45,8 @@ class RadioField extends Field
|
||||||
*/
|
*/
|
||||||
public function getRegistrationRules(Form $form): array
|
public function getRegistrationRules(Form $form): array
|
||||||
{
|
{
|
||||||
$rules = $this->required ? ['required', 'string'] : ['nullable', 'string'];
|
|
||||||
|
|
||||||
if (!$this->allowcustom) {
|
|
||||||
$rules[] = Rule::in($this->options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
$this->key => $rules
|
$this->key => $this->required ? ['required', 'string', Rule::in($this->options)] : ['nullable', 'string', Rule::in($this->options)],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?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 = collect($section->fields)->map(function ($field) {
|
|
||||||
if ($field->type === 'DropdownField' || $field->type === 'RadioField') {
|
|
||||||
$field->allowcustom = false;
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
$section->fields = collect($section->fields)->map(function ($field) {
|
|
||||||
if ($field->type === 'DropdownField' || $field->type === 'RadioField') {
|
|
||||||
$field->allowcustom = false;
|
|
||||||
}
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4db01b7bc69b29b18ec333a522113d0a5a5acb99
|
Subproject commit ecf008f12130c8ba18fced50f0a6fe1378d88755
|
|
@ -28,15 +28,6 @@
|
||||||
inline
|
inline
|
||||||
@update:modelValue="$emit('update:modelValue', {...modelValue, required: $event})"
|
@update:modelValue="$emit('update:modelValue', {...modelValue, required: $event})"
|
||||||
></f-switch>
|
></f-switch>
|
||||||
<f-switch
|
|
||||||
id="allowcustom"
|
|
||||||
:model-value="modelValue.allowcustom"
|
|
||||||
label="Eigene Option erlauben"
|
|
||||||
size="sm"
|
|
||||||
name="allowcustom"
|
|
||||||
inline
|
|
||||||
@update:modelValue="$emit('update:modelValue', {...modelValue, allowcustom: $event})"
|
|
||||||
></f-switch>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Form\Enums\NamiType;
|
||||||
use App\Form\Enums\SpecialType;
|
use App\Form\Enums\SpecialType;
|
||||||
use App\Form\Mails\ConfirmRegistrationMail;
|
use App\Form\Mails\ConfirmRegistrationMail;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
|
use App\Form\Models\Participant;
|
||||||
use App\Group;
|
use App\Group;
|
||||||
use App\Group\Enums\Level;
|
use App\Group\Enums\Level;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
|
@ -170,12 +171,6 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
['letter.0' => 'Der gewählte Wert für Buchstabe ist ungültig.'],
|
['letter.0' => 'Der gewählte Wert für Buchstabe ist ungültig.'],
|
||||||
];
|
];
|
||||||
|
|
||||||
yield [
|
|
||||||
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->allowcustom(true),
|
|
||||||
['letter' => 'Z'],
|
|
||||||
null,
|
|
||||||
];
|
|
||||||
|
|
||||||
yield [
|
yield [
|
||||||
$this->checkboxesField('letter')->name('Buchstabe')->options(['A', 'B']),
|
$this->checkboxesField('letter')->name('Buchstabe')->options(['A', 'B']),
|
||||||
['letter' => 77],
|
['letter' => 77],
|
||||||
|
@ -225,19 +220,19 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
];
|
];
|
||||||
|
|
||||||
yield [
|
yield [
|
||||||
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->required(false)->allowcustom(false),
|
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->required(false),
|
||||||
['letter' => 'Z'],
|
['letter' => 'Z'],
|
||||||
['letter' => 'Der gewählte Wert für Buchstabe ist ungültig.']
|
['letter' => 'Der gewählte Wert für Buchstabe ist ungültig.']
|
||||||
];
|
];
|
||||||
|
|
||||||
yield [
|
yield [
|
||||||
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->required(true)->allowcustom(false),
|
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->required(true),
|
||||||
['letter' => 'Z'],
|
['letter' => 'Z'],
|
||||||
['letter' => 'Der gewählte Wert für Buchstabe ist ungültig.']
|
['letter' => 'Der gewählte Wert für Buchstabe ist ungültig.']
|
||||||
];
|
];
|
||||||
|
|
||||||
yield [
|
yield [
|
||||||
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->required(true)->allowcustom(false),
|
$this->dropdownField('letter')->name('Buchstabe')->options(['A', 'B'])->required(true),
|
||||||
['letter' => 'A'],
|
['letter' => 'A'],
|
||||||
null
|
null
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue