Skip to content

Commit

Permalink
Form editor v2 (#579)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
chiragchhatrala and JhumanJ authored Sep 23, 2024
1 parent 47ae11b commit d6181cd
Show file tree
Hide file tree
Showing 61 changed files with 2,541 additions and 2,626 deletions.
7 changes: 0 additions & 7 deletions api/app/Models/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class Form extends Model implements CachableAttributes
'removed_properties',

'title',
'description',
'tags',
'visibility',

Expand Down Expand Up @@ -177,12 +176,6 @@ public function getViewsCountAttribute()
});
}

public function setDescriptionAttribute($value)
{
// Strip out unwanted html
$this->attributes['description'] = Purify::clean($value);
}

public function setSubmittedTextAttribute($value)
{
// Strip out unwanted html
Expand Down
217 changes: 0 additions & 217 deletions api/app/Service/SeoMetaResolver.php

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();
}
}
});
}
};
6 changes: 2 additions & 4 deletions api/tests/Feature/Forms/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@

$this->assertDatabaseHas('forms', [
'id' => $form->id,
'title' => $form->title,
'description' => $form->description,
'title' => $form->title
]);
});

Expand Down Expand Up @@ -125,8 +124,7 @@
expect($workspace->forms()->count())->toBe(2);
$this->assertDatabaseHas('forms', [
'id' => $response->json('new_form.id'),
'title' => 'Copy of ' . $form->title,
'description' => $form->description,
'title' => 'Copy of ' . $form->title
]);
});

Expand Down
1 change: 0 additions & 1 deletion api/tests/Unit/TestHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@
$workspace = $this->createUserWorkspace($user);
$form = $this->makeForm($user, $workspace);
expect($form->title)->not()->toBeNull();
expect($form->description)->not()->toBeNull();
expect(count($form->properties))->not()->toBe(0);
});
12 changes: 11 additions & 1 deletion client/app.config.ts
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]'
}
}
}
}
})
6 changes: 5 additions & 1 deletion client/components/forms/ColorInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
:name="name"
>
<slot name="label">
<span>{{ label }}
<span
:class="[
theme.SelectInput.fontSize,
]"
>{{ label }}
<span
v-if="required"
class="text-red-500 required-dot"
Expand Down
2 changes: 1 addition & 1 deletion client/components/forms/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const formattedDate = (value) => {
try {
return format(new Date(value), props.dateFormat + (props.timeFormat == 12 ? ' p':' HH:mm'))
} catch (e) {
console.log('Error formatting date', e)
console.error('Error formatting date', e)
return ''
}
}
Expand Down
Loading

0 comments on commit d6181cd

Please sign in to comment.