-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form editor v2 #579
Form editor v2 #579
Changes from all commits
b122155
743f8d4
0e6bec2
99955ab
5247f40
87de29a
cfad61f
f5a0e24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -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(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+34
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure consistent timestamp handling in The Consider disabling timestamps in the 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->timestamps = false;
$form->save();
}
}
});
} This change ensures that the Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,16 @@ | ||||||||||||||||||||||||||||||||||||||
export default defineAppConfig({ | ||||||||||||||||||||||||||||||||||||||
ui: { | ||||||||||||||||||||||||||||||||||||||
primary: 'blue', | ||||||||||||||||||||||||||||||||||||||
gray: 'slate' | ||||||||||||||||||||||||||||||||||||||
gray: 'slate', | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
tabs: { | ||||||||||||||||||||||||||||||||||||||
wrapper:'space-y-0', | ||||||||||||||||||||||||||||||||||||||
list: { | ||||||||||||||||||||||||||||||||||||||
height: 'h-auto', | ||||||||||||||||||||||||||||||||||||||
tab: { | ||||||||||||||||||||||||||||||||||||||
height: 'h-[30px]' | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
Comment on lines
+6
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good addition of tab styling, but consider flexibility The addition of the However, I have a suggestion regarding the tab height: Consider using a more flexible approach for the tab height. The current fixed height of
Here's an example of how you might adjust this: tabs: {
wrapper:'space-y-0',
list: {
height: 'h-auto',
tab: {
- height: 'h-[30px]'
+ height: 'min-h-[2rem]'
}
}
} This change would maintain a minimum height while allowing the tab to grow if needed. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a check for existing 'Description' property
The
up()
method adds a new 'Description' property to the form's properties array if a description exists. However, there's no check to prevent adding duplicate 'Description' properties if the migration is run multiple times.Consider adding a check to ensure the 'Description' property doesn't already exist before adding it. Here's a suggested modification:
This change ensures that the 'Description' property is only added if it doesn't already exist, preventing potential duplicates.
Committable suggestion