Ad hint field
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
c3f58cebc6
commit
43821ec416
|
@ -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()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
|
@ -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"
|
||||
|
|
|
@ -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