Add export to form
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
c7fc76466e
commit
93d30d10eb
|
@ -34,6 +34,7 @@ class FormStoreAction
|
|||
'mailattachments' => 'present|array|exclude',
|
||||
'is_active' => 'boolean',
|
||||
'is_private' => 'boolean',
|
||||
'export' => 'nullable|array',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class FormUpdateAction
|
|||
'mail_bottom' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'is_private' => 'boolean',
|
||||
'export' => 'nullable|array',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Data;
|
||||
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Fields\Field;
|
||||
use Spatie\LaravelData\Attributes\MapInputName;
|
||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\Mappers\SnakeCaseMapper;
|
||||
|
||||
#[MapInputName(SnakeCaseMapper::class)]
|
||||
#[MapOutputName(SnakeCaseMapper::class)]
|
||||
class ExportData extends Data
|
||||
{
|
||||
public function __construct(public ?FileshareResourceData $root = null, public ?string $groupBy = null, public ?string $toGroupField = null)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Models;
|
||||
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Data\FieldCollection;
|
||||
use App\Form\Data\FormConfigData;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
|
@ -33,6 +34,7 @@ class Form extends Model implements HasMedia
|
|||
'mail_bottom' => 'json',
|
||||
'is_active' => 'boolean',
|
||||
'is_private' => 'boolean',
|
||||
'export' => ExportData::class,
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Resources;
|
||||
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Enums\NamiType;
|
||||
use App\Form\Enums\SpecialType;
|
||||
use App\Form\Fields\Field;
|
||||
|
@ -47,6 +48,7 @@ class FormResource extends JsonResource
|
|||
'is_active' => $this->is_active,
|
||||
'is_private' => $this->is_private,
|
||||
'has_nami_field' => $this->getFields()->hasNamiField(),
|
||||
'export' => $this->export,
|
||||
'links' => [
|
||||
'participant_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => null]),
|
||||
'participant_root_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => -1]),
|
||||
|
@ -92,6 +94,7 @@ class FormResource extends JsonResource
|
|||
'header_image' => null,
|
||||
'mailattachments' => [],
|
||||
'id' => null,
|
||||
'export' => ExportData::from([]),
|
||||
],
|
||||
'section_default' => [
|
||||
'name' => '',
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Factories\Form\Models;
|
||||
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Models\Form;
|
||||
use Database\Factories\Traits\FakesMedia;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
@ -19,6 +20,7 @@ use Tests\RequestFactories\EditorRequestFactory;
|
|||
* @method self registrationUntil(string|null $date)
|
||||
* @method self isActive(bool $isActive)
|
||||
* @method self isPrivate(bool $isPrivate)
|
||||
* @method self export(ExportData $data)
|
||||
*/
|
||||
class FormFactory extends Factory
|
||||
{
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->json('export')->after('config')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropColumn('export');
|
||||
});
|
||||
}
|
||||
};
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Tests\EndToEnd\Form;
|
||||
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\FormSettings;
|
||||
use App\Form\Models\Form;
|
||||
use App\Form\Models\Formtemplate;
|
||||
|
@ -63,6 +65,7 @@ class FormIndexActionTest extends FormTestCase
|
|||
->assertInertiaPath('data.meta.default.is_active', true)
|
||||
->assertInertiaPath('data.meta.default.is_private', false)
|
||||
->assertInertiaPath('data.meta.default.mailattachments', [])
|
||||
->assertInertiaPath('data.meta.default.export', ['root' => null, 'group_by' => null, 'to_group_field' => null])
|
||||
->assertInertiaPath('data.meta.default.config', null)
|
||||
->assertInertiaPath('data.meta.base_url', url(''))
|
||||
->assertInertiaPath('data.meta.namiTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||
|
@ -70,6 +73,22 @@ class FormIndexActionTest extends FormTestCase
|
|||
->assertInertiaPath('data.meta.section_default.name', '');
|
||||
}
|
||||
|
||||
public function testItDisplaysExport(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Form::factory()
|
||||
->name('lala')
|
||||
->export(ExportData::from(['root' => FileshareResourceData::from(['connection_id' => 2, 'resource' => '/dir']), 'group_by' => 'lala', 'to_group_field' => 'abc']))
|
||||
->create();
|
||||
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertInertiaPath('data.data.0.export.group_by', 'lala')
|
||||
->assertInertiaPath('data.data.0.export.root.connection_id', 2)
|
||||
->assertInertiaPath('data.data.0.export.root.resource', '/dir')
|
||||
->assertInertiaPath('data.data.0.export.to_group_field', 'abc');
|
||||
}
|
||||
|
||||
public function testItHandlesFullTextSearch(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Tests\Feature\Form;
|
||||
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Enums\NamiType;
|
||||
use App\Form\Models\Form;
|
||||
use App\Lib\Events\Succeeded;
|
||||
|
@ -66,6 +68,16 @@ class FormStoreActionTest extends FormTestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testItStoresExport(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
|
||||
$this->postJson(route('form.store'), FormRequest::new()->export(ExportData::from(['root' => FileshareResourceData::from(['connection_id' => 2, 'resource' => '/dir']), 'group_by' => 'lala', 'to_group_field' => 'abc']))->create())->assertOk();
|
||||
|
||||
$form = Form::first();
|
||||
$this->assertEquals(2, $form->export->root->connectionId);
|
||||
}
|
||||
|
||||
public function validationDataProvider(): Generator
|
||||
{
|
||||
yield [FormRequest::new()->name(''), ['name' => 'Name ist erforderlich.']];
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Tests\Feature\Form;
|
||||
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Models\Form;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
@ -39,6 +41,16 @@ class FormUpdateActionTest extends FormTestCase
|
|||
$this->assertFrontendCacheCleared();
|
||||
}
|
||||
|
||||
public function testItUpdatesExport(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
|
||||
$form = Form::factory()->create();
|
||||
$this->patchJson(route('form.update', ['form' => $form]), FormRequest::new()->export(ExportData::from(['root' => FileshareResourceData::from(['connection_id' => 2, 'resource' => '/dir']), 'group_by' => 'lala', 'to_group_field' => 'abc']))->create());
|
||||
|
||||
$this->assertEquals(2, $form->fresh()->export->root->connectionId);
|
||||
}
|
||||
|
||||
public function testItUpdatesActiveColumnsWhenFieldRemoved(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
|
|
Loading…
Reference in New Issue