Add sorting and active_columns meta for form
This commit is contained in:
parent
09e3bcab9e
commit
3cbb4768e8
|
@ -27,7 +27,7 @@ class Form extends Model implements HasMedia
|
||||||
|
|
||||||
public $casts = [
|
public $casts = [
|
||||||
'config' => 'json',
|
'config' => 'json',
|
||||||
'active_columns' => 'json',
|
'meta' => 'json',
|
||||||
'description' => 'json',
|
'description' => 'json',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -138,8 +138,11 @@ class Form extends Model implements HasMedia
|
||||||
public static function booted(): void
|
public static function booted(): void
|
||||||
{
|
{
|
||||||
static::saving(function (self $model) {
|
static::saving(function (self $model) {
|
||||||
if (is_null($model->active_columns)) {
|
if (is_null($model->meta)) {
|
||||||
$model->setAttribute('active_columns', $model->getFields()->take(4)->pluck('key')->toArray());
|
$model->setAttribute('meta', [
|
||||||
|
'active_columns' => $model->getFields()->take(4)->pluck('key')->toArray(),
|
||||||
|
'sorting' => [$model->getFields()->first()['key'], 'asc'],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ return new class extends Migration
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->string('slug');
|
$table->string('slug');
|
||||||
$table->text('description');
|
$table->json('description');
|
||||||
$table->text('excerpt');
|
$table->text('excerpt');
|
||||||
$table->json('config');
|
$table->json('config');
|
||||||
$table->date('from');
|
$table->date('from');
|
||||||
|
@ -33,7 +33,7 @@ return new class extends Migration
|
||||||
$table->dateTime('registration_until')->nullable();
|
$table->dateTime('registration_until')->nullable();
|
||||||
$table->text('mail_top')->nullable();
|
$table->text('mail_top')->nullable();
|
||||||
$table->text('mail_bottom')->nullable();
|
$table->text('mail_bottom')->nullable();
|
||||||
$table->json('active_columns');
|
$table->json('meta');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?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->dropColumn('description');
|
|
||||||
});
|
|
||||||
Schema::table('forms', function (Blueprint $table) {
|
|
||||||
$table->json('description')->after('name');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('forms', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('description');
|
|
||||||
});
|
|
||||||
Schema::table('forms', function (Blueprint $table) {
|
|
||||||
$table->text('description')->after('name');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -17,6 +17,7 @@ return new class extends Migration
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->json('data');
|
$table->json('data');
|
||||||
$table->foreignId('form_id');
|
$table->foreignId('form_id');
|
||||||
|
$table->string('mitgliedsnr')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?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('participants', function (Blueprint $table) {
|
|
||||||
$table->string('mitgliedsnr')->nullable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('participants', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('mitgliedsnr');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -39,5 +39,5 @@ var {meta, data, reload, reloadPage} = useApiIndex(props.url, 'participant');
|
||||||
|
|
||||||
await reload();
|
await reload();
|
||||||
|
|
||||||
const activeColumns = computed(() => meta.value.columns.filter((c) => meta.value.active_columns.includes(c.id)));
|
const activeColumns = computed(() => meta.value.columns.filter((c) => meta.value.form_meta.active_columns.includes(c.id)));
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -10,7 +10,6 @@ use App\Member\Member;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Generator;
|
use Generator;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Testing\TestResponse;
|
use Illuminate\Testing\TestResponse;
|
||||||
|
|
||||||
class FormRegisterActionTest extends FormTestCase
|
class FormRegisterActionTest extends FormTestCase
|
||||||
|
@ -18,13 +17,6 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
|
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
Storage::fake('temp');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItSavesParticipantAsModel(): void
|
public function testItSavesParticipantAsModel(): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
|
|
|
@ -16,13 +16,6 @@ class FormStoreActionTest extends FormTestCase
|
||||||
|
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
Storage::fake('temp');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItStoresForm(): void
|
public function testItStoresForm(): void
|
||||||
{
|
{
|
||||||
Event::fake([Succeeded::class]);
|
Event::fake([Succeeded::class]);
|
||||||
|
|
|
@ -2,10 +2,18 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Form;
|
namespace Tests\Feature\Form;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Tests\Lib\CreatesFormFields;
|
use Tests\Lib\CreatesFormFields;
|
||||||
|
|
||||||
class FormTestCase extends TestCase
|
class FormTestCase extends TestCase
|
||||||
{
|
{
|
||||||
use CreatesFormFields;
|
use CreatesFormFields;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Storage::fake('temp');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,6 @@ class FormUpdateActionTest extends FormTestCase
|
||||||
|
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
Storage::fake('temp');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItSetsCustomAttributesOfFields(): void
|
public function testItSetsCustomAttributesOfFields(): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
|
|
|
@ -50,7 +50,8 @@ class ParticipantIndexActionTest extends FormTestCase
|
||||||
->assertJsonPath('meta.columns.0.id', 'vorname')
|
->assertJsonPath('meta.columns.0.id', 'vorname')
|
||||||
->assertJsonPath('meta.columns.6.display_attribute', 'birthday_display')
|
->assertJsonPath('meta.columns.6.display_attribute', 'birthday_display')
|
||||||
->assertJsonPath('meta.columns.0.display_attribute', 'vorname_display')
|
->assertJsonPath('meta.columns.0.display_attribute', 'vorname_display')
|
||||||
->assertJsonPath('meta.active_columns', ['vorname', 'select', 'stufe', 'test1']);
|
->assertJsonPath('meta.form_meta.active_columns', ['vorname', 'select', 'stufe', 'test1'])
|
||||||
|
->assertJsonPath('meta.form_meta.sorting', ['vorname', 'asc']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItPresentsNamiField(): void
|
public function testItPresentsNamiField(): void
|
||||||
|
|
Loading…
Reference in New Issue