Form editor v2 (#579)

* Form editor v2

* fix template test

* setFormDefaults when save

* fix form cleaning dark mode

* improvements on open sidebar

* UI polish

* Fix change type button

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2024-09-23 23:32:38 +05:30
committed by GitHub
parent 47ae11bc58
commit d6181cd249
61 changed files with 2576 additions and 2661 deletions

View File

@@ -0,0 +1,47 @@
<?php
use App\Models\Forms\Form;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Str;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Form::chunk(100, function ($forms) {
foreach ($forms as $form) {
$properties = $form->properties;
if (!empty($form->description)) {
array_unshift($properties, [
'type' => 'nf-text',
'content' => $form->description,
'name' => 'Description',
'id' => Str::uuid()
]);
$form->properties = $properties;
$form->timestamps = false;
$form->save();
}
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Form::chunk(100, function ($forms) {
foreach ($forms as $form) {
$properties = $form->properties;
if (!empty($properties) && $properties[0]['type'] === 'nf-text' && $properties[0]['name'] === 'Description') {
array_shift($properties);
$form->properties = $properties;
$form->save();
}
}
});
}
};