Skip to content

Commit

Permalink
fix: webform create page bug, edit page bug and preview page bug
Browse files Browse the repository at this point in the history
  • Loading branch information
devansh-webkul committed Jan 21, 2025
1 parent 601e3a2 commit 911c3c0
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ public function create(): View
$attributes = [];

foreach ($tempAttributes as $attribute) {
if ($attribute->entity_type == 'persons'
&& (
$attribute->code == 'name'
|| $attribute->code == 'emails'
|| $attribute->code == 'contact_numbers'
)
if (
$attribute->entity_type == 'persons'
&& in_array($attribute->code, ['name', 'emails', 'contact_numbers'])
) {
$attributes['default'][] = $attribute;
} else {
Expand Down Expand Up @@ -156,7 +153,7 @@ public function destroy(int $id): JsonResponse

return response()->json([
'message' => trans('admin::app.settings.webforms.index.delete-success'),
], 200);
]);
} catch (\Exception $exception) {
return response()->json([
'message' => trans('admin::app.settings.webforms.index.delete-failed'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
{!! view_render_event('admin.dashboard.index.content.after') !!}

@pushOnce('scripts')

<script
type="module"
src="{{ vite()->asset('js/chart.js') }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="flex items-center gap-x-2.5">
{!! view_render_event('admin.settings.webform.create.save_button.before') !!}

<!-- Create button for person -->
<!-- Create Button -->
<button
type="submit"
class="primary-button"
Expand All @@ -51,7 +51,7 @@ class="primary-button"
<div class="flex gap-2.5 max-xl:flex-wrap">
{!! view_render_event('admin.settings.webform.create.left.before') !!}
<!-- Left sub-component -->
<!-- Left Sub Component -->
<div class="flex flex-1 flex-col gap-2 max-xl:flex-auto">
<div class="box-shadow rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-800 dark:bg-gray-900">
<div class="mb-4 flex items-center justify-between gap-4">
Expand All @@ -64,7 +64,7 @@ class="primary-button"
{!! view_render_event('admin.settings.webform.create.form_controls.before') !!}
<!-- Submit success actions -->
<!-- Submit Success Actions -->
<x-admin::form.control-group>
<x-admin::form.control-group.label class="required">
@lang('admin::app.settings.webforms.create.submit-success-action')
Expand Down Expand Up @@ -125,7 +125,7 @@ class="peer sr-only"
</label>
</x-admin::form.control-group>
<!-- Customize webform -->
<!-- Customize Webform -->
<div class="mb-4 flex items-center justify-between gap-4">
<div class="flex flex-col gap-1">
<p class="text-base font-semibold text-gray-800 dark:text-white">
Expand All @@ -138,7 +138,7 @@ class="peer sr-only"
</div>
</div>
<!-- Backgroud Color Picker -->
<!-- Background Color Picker -->
<v-color-picker
name="background_color"
title="@lang('admin::app.settings.webforms.create.background-color')"
Expand All @@ -160,7 +160,7 @@ class="w-1/5"
</x-admin::form.control-group>
</v-color-picker>
<!-- Backgroud Color Picker -->
<!-- Background Color Picker -->
<v-color-picker
name="form_background_color"
title="@lang('admin::app.settings.webforms.create.form-background-color')"
Expand All @@ -184,7 +184,7 @@ class="w-1/5"
</x-admin::form.control-group>
</v-color-picker>
<!-- Backgroud Color Picker -->
<!-- Background Color Picker -->
<v-color-picker
name="form_title_color"
title="@lang('admin::app.settings.webforms.create.form-title-color')"
Expand Down Expand Up @@ -367,23 +367,41 @@ class="whitespace-no-wrap flex cursor-pointer items-center justify-between gap-1
</x-admin::form.control-group>
</x-admin::table.td>
<!-- Required or Not -->
<!-- Required Or Not -->
<x-admin::table.td>
<x-admin::form.control-group class="!mt-6">
<label :for="'attributes[' + element.id + '][is_required]'">
<!--
When the checkbox is disabled for name and email, we will set a hidden value
because the form will not send the value of disabled input fields.
-->
<input
type="hidden"
:name="'attributes[' + element.id + '][is_required]'"
:value="1"
v-if="['name', 'emails'].includes(element['attribute']['code'])"
>
<!--
Only the name and email fields are required, so we will disable the checkbox and
force the user to provide them.
-->
<input
type="checkbox"
:name="'attributes[' + element.id + '][is_required]'"
:id="'attributes[' + element.id + '][is_required]'"
:value="1"
class="peer hidden"
:checked="element.is_required"
:disabled="element.attribute.is_required ? true : false"
:disabled="['name', 'emails'].includes(element['attribute']['code'])"
>
<!--
We will display a disabled checkbox for the name and email fields.
-->
<span
class='icon-checkbox-outline peer-checked:icon-checkbox-select cursor-pointer rounded-md text-2xl peer-checked:text-brandColor'
:class="{'opacity-50' : element.attribute.is_required}"
:class="{'opacity-50' : ['name', 'emails'].includes(element['attribute']['code'])}"
></span>
</label>
</x-admin::form.control-group>
Expand All @@ -394,7 +412,7 @@ class='icon-checkbox-outline peer-checked:icon-checkbox-select cursor-pointer ro
<x-admin::form.control-group class="!mt-6">
<i
class="icon-delete cursor-pointer text-2xl"
v-if="element['attribute']['code'] != 'name' && element['attribute']['code'] != 'emails'"
v-if="! ['name', 'emails'].includes(element['attribute']['code'])"
@click="removeAttribute(element)"
></i>
</x-admin::form.control-group>
Expand All @@ -412,7 +430,7 @@ class="icon-delete cursor-pointer text-2xl"
{!! view_render_event('admin.settings.webform.create.right.before') !!}
<!-- Right sub-component -->
<!-- Right Sub Component -->
<div class="flex w-[360px] max-w-full flex-col gap-2 max-sm:w-full">
<x-admin::accordion class="rounded-lg">
<x-slot:header>
Expand Down Expand Up @@ -461,7 +479,7 @@ class="icon-delete cursor-pointer text-2xl"
<x-admin::form.control-group.error control-name="description" />
</x-admin::form.control-group>
<!-- Submit button label -->
<!-- Submit Button Label -->
<x-admin::form.control-group class="!mb-0">
<x-admin::form.control-group.label class="required">
@lang('admin::app.settings.webforms.create.submit-button-label')
Expand Down
Loading

0 comments on commit 911c3c0

Please sign in to comment.