refresh form extension admin interface
Improve form editing, settings, submission lists, and navigation with responsive layouts and accessibility enhancements. Update the form wrapper block view and regenerate the extension stylesheet. Ignore .agents and skills-lock.json.
This commit is contained in:
+2
-1
@@ -17,7 +17,8 @@ cache
|
||||
uploads
|
||||
extensions/dev_*
|
||||
docs
|
||||
docs/*
|
||||
.agents
|
||||
skills-lock.json
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
|
||||
@@ -21,7 +21,7 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
|
||||
<div class="mb-6">
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="?tab=ext--form" class="btn btn-ghost btn-sm btn-circle">
|
||||
<a href="?tab=ext--form" class="btn btn-ghost btn-sm btn-circle" aria-label="Back to forms" title="Back to forms">
|
||||
<i class="ph-duotone ph-arrow-left text-xl"></i>
|
||||
</a>
|
||||
<div>
|
||||
@@ -104,36 +104,36 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
if(isset($form['id'])) echo '<input type="hidden" name="id" value="'.$form['id'].'">';
|
||||
?>
|
||||
|
||||
<div class="card bg-base-100 shadow mb-6">
|
||||
<div class="card mb-6 border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="flex items-center gap-2 mb-4">
|
||||
<i class="ph-duotone ph-text-aa text-2xl text-base-content/60"></i>
|
||||
<i class="ph-duotone ph-text-aa text-2xl text-primary" aria-hidden="true"></i>
|
||||
<h3 class="card-title text-lg">Basics</h3>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="form-name">
|
||||
<span class="label-text font-medium">Form name</span>
|
||||
</label>
|
||||
<input type="text" name="name" value="<?= $form['name'] ?>" placeholder="e.g. Contact form" class="input input-bordered w-full" required />
|
||||
<input id="form-name" type="text" name="name" value="<?= phpb_e($form['name']) ?>" placeholder="e.g. Contact form" class="input input-bordered w-full" required />
|
||||
<span class="label-text-alt text-base-content/60">A unique name for your form.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-base-100 shadow mb-6">
|
||||
<div class="card mb-6 border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="flex items-center gap-2 mb-4">
|
||||
<i class="ph-duotone ph-list-dashes text-2xl text-base-content/60"></i>
|
||||
<i class="ph-duotone ph-list-dashes text-2xl text-primary" aria-hidden="true"></i>
|
||||
<h3 class="card-title text-lg">Form fields</h3>
|
||||
</div>
|
||||
<p class="text-sm text-base-content/60 mb-4">Define the fields users can fill out.</p>
|
||||
|
||||
<input type="hidden" name="fields" :value="JSON.stringify(fields)">
|
||||
|
||||
<div x-show="fields.length === 0" class="text-center py-8 border-2 border-dashed border-base-300 rounded-lg">
|
||||
<div x-show="fields.length === 0" class="rounded-box border-2 border-dashed border-base-300 px-4 py-8 text-center">
|
||||
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30"></i>
|
||||
<p class="text-sm text-base-content/50 mt-2">No fields added yet</p>
|
||||
<a href="javascript:void(0)" @click="addField()" class="btn btn-sm btn-primary mt-2">Add your first field</a>
|
||||
<button type="button" @click="addField()" class="btn btn-sm btn-primary mt-2">Add your first field</button>
|
||||
</div>
|
||||
|
||||
<div x-show="fields.length > 0" class="space-y-3">
|
||||
@@ -151,33 +151,35 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
@drop.prevent="moveField(dragIndex, index)"
|
||||
@dragend="dragIndex = null"
|
||||
>
|
||||
<div class="flex items-center gap-2 mb-2">
|
||||
<div class="mb-2 flex flex-col gap-2 sm:flex-row sm:items-center">
|
||||
<!-- Drag handle -->
|
||||
<button type="button" class="btn btn-ghost btn-xs btn-square cursor-grab active:cursor-grabbing text-base-content/40 hover:text-base-content" title="Drag to move">
|
||||
<button type="button" class="btn btn-ghost btn-xs btn-square cursor-grab active:cursor-grabbing text-base-content/40 hover:text-base-content" title="Drag to move" aria-label="Drag to move field">
|
||||
<i class="ph-duotone ph-dots-six-vertical text-lg"></i>
|
||||
</button>
|
||||
<span class="text-xs font-mono text-base-content/40 w-6">#[<span x-text="index + 1"></span>]</span>
|
||||
<div class="flex-1">
|
||||
<div class="w-full flex-1">
|
||||
<input
|
||||
type="text"
|
||||
x-model="field.name"
|
||||
placeholder="Field name"
|
||||
placeholder="Field name"
|
||||
:aria-label="'Field ' + (index + 1) + ' name'"
|
||||
class="input input-bordered input-sm w-full"
|
||||
:class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Field name'))}"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<div class="w-full flex-1">
|
||||
<input
|
||||
type="text"
|
||||
x-model="field.label"
|
||||
placeholder="Label"
|
||||
placeholder="Label"
|
||||
:aria-label="'Field ' + (index + 1) + ' label'"
|
||||
class="input input-bordered input-sm w-full"
|
||||
:class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Label'))}"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Validation errors -->
|
||||
<div x-show="getValidationErrors(field, index).length > 0" x-transition class="mb-2 p-2 bg-error/10 border border-error/30 rounded text-error text-xs">
|
||||
<div x-show="getValidationErrors(field, index).length > 0" x-transition class="mb-2 rounded border border-error/30 bg-error/10 p-2 text-xs text-error" role="alert" aria-live="polite">
|
||||
<template x-for="(error, errIndex) in getValidationErrors(field, index)">
|
||||
<div :key="errIndex" class="flex items-center gap-1">
|
||||
<i class="ph-duotone ph-warning text-sm"></i>
|
||||
@@ -185,8 +187,8 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<select x-model="field.type" class="select select-bordered select-sm flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<select x-model="field.type" class="select select-bordered select-sm min-w-40 flex-1" :aria-label="'Field ' + (index + 1) + ' type'">
|
||||
<option value="text">Text</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="textarea">Text area</option>
|
||||
@@ -196,27 +198,27 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
</select>
|
||||
<label class="label cursor-pointer gap-2">
|
||||
<span class="label-text text-sm">Required</span>
|
||||
<input type="checkbox" x-model="field.required" class="checkbox checkbox-sm checkbox-primary" />
|
||||
<input type="checkbox" x-model="field.required" class="checkbox checkbox-sm checkbox-primary" :aria-label="'Field ' + (index + 1) + ' is required'" />
|
||||
</label>
|
||||
<button @click="fields.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove">
|
||||
<button @click="fields.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove" :aria-label="'Remove field ' + (index + 1)">
|
||||
<i class="ph-duotone ph-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div x-show="field.type === 'select' || field.type === 'checkbox' || field.type === 'radio'" x-transition class="mt-3 ml-2 pl-4 border-l-2 border-primary/30">
|
||||
<div x-show="field.type === 'select' || field.type === 'checkbox' || field.type === 'radio'" x-transition class="mt-3 border-l-2 border-primary/30 pl-3 sm:ml-2 sm:pl-4">
|
||||
<div class="flex items-center gap-2 mb-2">
|
||||
<span class="text-xs font-medium text-base-content/60 uppercase tracking-wide" x-text="getOptionsLabel(field.type)"></span>
|
||||
<a href="javascript:void(0)" @click="field.options.push({label: 'Option', value: 'option'})" class="btn btn-xs btn-ghost btn-primary">
|
||||
<button type="button" @click="field.options.push({label: 'Option', value: 'option'})" class="btn btn-xs btn-ghost btn-primary">
|
||||
<i class="ph-duotone ph-plus"></i>
|
||||
Add
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
<div class="space-y-1">
|
||||
<template x-for="(option, optIndex) in field.options">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex flex-col gap-2 sm:flex-row sm:items-center">
|
||||
<span class="text-xs text-base-content/40 w-4">#[<span x-text="optIndex + 1"></span>]</span>
|
||||
<input type="text" x-model="option.label" placeholder="Label" class="input input-bordered input-sm flex-1" />
|
||||
<input type="text" x-model="option.value" placeholder="Value" class="input input-bordered input-sm flex-1" />
|
||||
<button @click="field.options.splice(optIndex, 1)" type="button" class="btn btn-ghost btn-xs btn-circle text-error" title="Remove">
|
||||
<input type="text" x-model="option.label" placeholder="Label" class="input input-bordered input-sm w-full flex-1" :aria-label="'Field ' + (index + 1) + ' option ' + (optIndex + 1) + ' label'" />
|
||||
<input type="text" x-model="option.value" placeholder="Value" class="input input-bordered input-sm w-full flex-1" :aria-label="'Field ' + (index + 1) + ' option ' + (optIndex + 1) + ' value'" />
|
||||
<button @click="field.options.splice(optIndex, 1)" type="button" class="btn btn-ghost btn-xs btn-circle text-error" title="Remove" :aria-label="'Remove option ' + (optIndex + 1) + ' from field ' + (index + 1)">
|
||||
<i class="ph-duotone ph-x"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -228,28 +230,28 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<a href="javascript:void(0)" @click="addField()" class="btn btn-outline btn-sm btn-primary">
|
||||
<button type="button" @click="addField()" class="btn btn-outline btn-sm btn-primary">
|
||||
<i class="ph-duotone ph-plus"></i>
|
||||
Add field
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card bg-base-100 shadow mb-6">
|
||||
<div class="card mb-6 border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="flex items-center gap-2 mb-4">
|
||||
<i class="ph-duotone ph-gear text-2xl text-base-content/60"></i>
|
||||
<i class="ph-duotone ph-gear text-2xl text-primary" aria-hidden="true"></i>
|
||||
<h3 class="card-title text-lg">Actions</h3>
|
||||
</div>
|
||||
<p class="text-sm text-base-content/60 mb-4">What should happen when a form is submitted?</p>
|
||||
|
||||
<input type="hidden" name="finishers" :value="JSON.stringify(finishers)">
|
||||
|
||||
<div x-show="finishers.length === 0" class="text-center py-8 border-2 border-dashed border-base-300 rounded-lg">
|
||||
<div x-show="finishers.length === 0" class="rounded-box border-2 border-dashed border-base-300 px-4 py-8 text-center">
|
||||
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30"></i>
|
||||
<p class="text-sm text-base-content/50 mt-2">No actions added yet</p>
|
||||
<a href="javascript:void(0)" @click="addFinisher()" class="btn btn-sm btn-primary mt-2">Add your first action</a>
|
||||
<button type="button" @click="addFinisher()" class="btn btn-sm btn-primary mt-2">Add your first action</button>
|
||||
</div>
|
||||
|
||||
<div x-show="finishers.length > 0" class="space-y-2">
|
||||
@@ -257,21 +259,21 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
<div class="p-3 border border-base-300 rounded-lg bg-base-200/50 space-y-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-xs font-mono text-base-content/40">#[<span x-text="index + 1"></span>]</span>
|
||||
<select :value="finisher.type" @change="setFinisherType(finisher, $event.target.value)" class="select select-bordered select-sm flex-1">
|
||||
<select :value="finisher.type" @change="setFinisherType(finisher, $event.target.value)" class="select select-bordered select-sm min-w-40 flex-1" :aria-label="'Action ' + (index + 1) + ' type'">
|
||||
<template x-for="(definition, type) in finisherDefinitions" :key="type">
|
||||
<option :value="type" x-text="definition.label"></option>
|
||||
</template>
|
||||
</select>
|
||||
<button @click="finishers.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove">
|
||||
<button @click="finishers.splice(index, 1)" type="button" class="btn btn-ghost btn-sm btn-circle text-error" title="Remove" :aria-label="'Remove action ' + (index + 1)">
|
||||
<i class="ph-duotone ph-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div x-show="getFinisherSettings(finisher.type).length > 0" class="space-y-3 pl-8">
|
||||
<template x-for="setting in getFinisherSettings(finisher.type)" :key="setting.name">
|
||||
<div class="form-control">
|
||||
<label class="label"><span class="label-text" x-text="setting.label"></span></label>
|
||||
<label class="label" :for="'finisher-' + index + '-' + setting.name"><span class="label-text" x-text="setting.label"></span></label>
|
||||
<template x-if="setting.type === 'emailField'">
|
||||
<select x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
|
||||
<select :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
|
||||
<option value="">Select an email field</option>
|
||||
<template x-for="field in fields.filter(field => field.type === 'email')" :key="field.name">
|
||||
<option :value="field.name" x-text="field.label + ' (' + field.name + ')' "></option>
|
||||
@@ -279,17 +281,17 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
</select>
|
||||
</template>
|
||||
<template x-if="setting.type === 'select'">
|
||||
<select x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
|
||||
<select :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :required="setting.required || false" class="select select-bordered select-sm w-full">
|
||||
<template x-for="option in setting.options || []" :key="option.value">
|
||||
<option :value="option.value" x-text="option.label"></option>
|
||||
</template>
|
||||
</select>
|
||||
</template>
|
||||
<template x-if="setting.type === 'textarea'">
|
||||
<textarea x-model="finisher.options[setting.name]" :required="setting.required || false" :placeholder="setting.placeholder || ''" class="textarea textarea-bordered w-full" rows="4"></textarea>
|
||||
<textarea :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :required="setting.required || false" :placeholder="setting.placeholder || ''" class="textarea textarea-bordered w-full" rows="4"></textarea>
|
||||
</template>
|
||||
<template x-if="!['emailField', 'select', 'textarea'].includes(setting.type)">
|
||||
<input x-model="finisher.options[setting.name]" :type="setting.type" :required="setting.required || false" :min="setting.min" :max="setting.max" :placeholder="setting.placeholder || ''" class="input input-bordered input-sm w-full" />
|
||||
<input :id="'finisher-' + index + '-' + setting.name" x-model="finisher.options[setting.name]" :type="setting.type" :required="setting.required || false" :min="setting.min" :max="setting.max" :placeholder="setting.placeholder || ''" class="input input-bordered input-sm w-full" />
|
||||
</template>
|
||||
<span x-show="setting.help" class="label-text-alt text-base-content/60 mt-1" x-text="setting.help"></span>
|
||||
</div>
|
||||
@@ -301,19 +303,19 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<a href="javascript:void(0)" @click="addFinisher()" class="btn btn-outline btn-sm btn-primary">
|
||||
<button type="button" @click="addFinisher()" class="btn btn-outline btn-sm btn-primary">
|
||||
<i class="ph-duotone ph-plus"></i>
|
||||
Add action
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<a href="?tab=ext--form" class="btn btn-ghost btn-sm">
|
||||
<div class="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
|
||||
<a href="?tab=ext--form" class="btn btn-ghost btn-sm sm:min-w-28">
|
||||
Cancel
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary btn-sm">
|
||||
<button type="submit" class="btn btn-primary btn-sm sm:min-w-28">
|
||||
<i class="ph-duotone ph-floppy-disk"></i>
|
||||
Save
|
||||
</button>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<div class="card bg-base-100 shadow">
|
||||
<section class="card border border-base-300/60 bg-base-100 shadow-sm" aria-labelledby="form-extension-settings-title">
|
||||
<div class="card-body">
|
||||
<div class="flex items-center gap-2 mb-4">
|
||||
<i class="ph-duotone ph-gear text-2xl text-base-content/60"></i>
|
||||
<h3 class="card-title text-lg">Settings</h3>
|
||||
<div class="flex items-start gap-3 border-b border-base-300/60 pb-4">
|
||||
<i class="ph-duotone ph-gear mt-1 text-2xl text-primary" aria-hidden="true"></i>
|
||||
<div>
|
||||
<h2 class="card-title text-lg" id="form-extension-settings-title">Settings</h2>
|
||||
<p class="mt-1 text-sm text-base-content/60">Configure the global settings for the Form extension.</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm text-base-content/60 mb-4">Configure the global settings for the Form extension.</p>
|
||||
<div class="space-y-4">
|
||||
<div class="space-y-5 pt-2">
|
||||
<?php
|
||||
foreach (\Plugi\Extensions::getSettings('form') as $setting) {
|
||||
phpb_render_setting($setting);
|
||||
@@ -13,4 +15,4 @@
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -15,7 +15,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
|
||||
|
||||
<div class="mb-6">
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form']) ?>" class="btn btn-ghost btn-sm btn-circle">
|
||||
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form']) ?>" class="btn btn-ghost btn-sm btn-circle" aria-label="Back to forms" title="Back to forms">
|
||||
<i class="ph-duotone ph-arrow-left text-xl"></i>
|
||||
</a>
|
||||
<div>
|
||||
@@ -26,7 +26,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
|
||||
</div>
|
||||
|
||||
<?php if (empty($entries)): ?>
|
||||
<div class="card bg-base-100 shadow">
|
||||
<div class="card border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body items-center text-center py-16">
|
||||
<i class="ph-duotone ph-inbox text-6xl text-base-content/20"></i>
|
||||
<h3 class="card-title text-lg mt-4">No submissions yet</h3>
|
||||
@@ -34,7 +34,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="card bg-base-100 shadow">
|
||||
<div class="card border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table w-full">
|
||||
@@ -45,7 +45,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
|
||||
<?php foreach ($fields as $field): ?>
|
||||
<th><?= phpb_e($field['label']) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th class="w-12 text-center"><?= phpb_trans('website-manager.actions') ?></th>
|
||||
<th class="w-40 text-right"><?= phpb_trans('website-manager.actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -71,8 +71,8 @@ $entries = $entriesRepository->findWhere('formId', $id);
|
||||
<td class="text-sm"><?= phpb_e($fieldValue) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td>
|
||||
<div class="flex justify-center">
|
||||
<a href="/ext--form/delete-entry?id=<?= $entry['id'] ?>&formId=<?= $id ?>" class="btn btn-ghost btn-sm btn-circle text-error" title="<?= phpb_trans('website-manager.remove') ?>">
|
||||
<div class="flex justify-end">
|
||||
<a href="/ext--form/delete-entry?id=<?= $entry['id'] ?>&formId=<?= $id ?>" class="btn btn-ghost btn-sm btn-circle text-error" title="<?= phpb_trans('website-manager.remove') ?>" aria-label="<?= phpb_trans('website-manager.remove') ?> submission <?= phpb_e($entry['id']) ?>">
|
||||
<i class="ph-duotone ph-trash text-lg"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ $forms = $formsRepository->getAll();
|
||||
|
||||
?>
|
||||
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold">Forms</h2>
|
||||
<p class="text-sm text-base-content/60"><?= count($forms) ?> form<?= count($forms) !== 1 ? 's' : '' ?> available</p>
|
||||
@@ -18,7 +18,7 @@ $forms = $formsRepository->getAll();
|
||||
</div>
|
||||
|
||||
<?php if (empty($forms)): ?>
|
||||
<div class="card bg-base-100 shadow">
|
||||
<div class="card border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body items-center text-center py-16">
|
||||
<i class="ph-duotone ph-notebook text-6xl text-base-content/20"></i>
|
||||
<h3 class="card-title text-lg mt-4">No forms yet</h3>
|
||||
@@ -30,7 +30,7 @@ $forms = $formsRepository->getAll();
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="card bg-base-100 shadow">
|
||||
<div class="card border border-base-300/60 bg-base-100 shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table w-full">
|
||||
@@ -38,7 +38,7 @@ $forms = $formsRepository->getAll();
|
||||
<tr class="bg-base-200/50">
|
||||
<th class="w-16">ID</th>
|
||||
<th><?= phpb_trans('website-manager.name') ?></th>
|
||||
<th class="w-16 text-center"><?= phpb_trans('website-manager.actions') ?></th>
|
||||
<th class="w-40 text-right"><?= phpb_trans('website-manager.actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -49,14 +49,14 @@ $forms = $formsRepository->getAll();
|
||||
<div class="font-medium"><?= phpb_e($form['name']) ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex items-center justify-center gap-1">
|
||||
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'listEntries', 'id' => $form['id']]) ?>" class="btn btn-ghost btn-sm btn-circle" title="View entries">
|
||||
<div class="flex items-center justify-end gap-1">
|
||||
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'listEntries', 'id' => $form['id']]) ?>" class="btn btn-ghost btn-sm btn-circle" title="View entries" aria-label="View entries for <?= phpb_e($form['name']) ?>">
|
||||
<i class="ph-duotone ph-eye text-lg"></i>
|
||||
</a>
|
||||
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'editForm', 'id' => $form['id']]) ?>" class="btn btn-ghost btn-sm btn-circle" title="<?= phpb_trans('website-manager.edit') ?>">
|
||||
<a href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => 'editForm', 'id' => $form['id']]) ?>" class="btn btn-ghost btn-sm btn-circle" title="<?= phpb_trans('website-manager.edit') ?>" aria-label="<?= phpb_trans('website-manager.edit') ?> <?= phpb_e($form['name']) ?>">
|
||||
<i class="ph-duotone ph-pencil-line text-lg"></i>
|
||||
</a>
|
||||
<a href="/ext--form/delete-form?id=<?= $form['id'] ?>" class="btn btn-ghost btn-sm btn-circle text-error" title="<?= phpb_trans('website-manager.remove') ?>">
|
||||
<a href="/ext--form/delete-form?id=<?= $form['id'] ?>" class="btn btn-ghost btn-sm btn-circle text-error" title="<?= phpb_trans('website-manager.remove') ?>" aria-label="<?= phpb_trans('website-manager.remove') ?> <?= phpb_e($form['name']) ?>">
|
||||
<i class="ph-duotone ph-trash text-lg"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -33,13 +33,14 @@ if (isset($_GET['action']) && array_key_exists($_GET['action'], $modules)) $acti
|
||||
<?php
|
||||
if ($modules[$activeModule]['showTabs'] === true):
|
||||
?>
|
||||
<div class="tabs tabs-boxed bg-base-200/50 mb-6">
|
||||
<nav class="mb-6 overflow-x-auto" aria-label="Form extension navigation">
|
||||
<div class="tabs tabs-boxed w-max min-w-full bg-base-200/50">
|
||||
<?php
|
||||
foreach ($modules as $name => $module):
|
||||
if ($module['inMenu'] === false) continue;
|
||||
$icon = $module['icon'] ?? 'ph-circle';
|
||||
?>
|
||||
<a class="tab gap-2 <?= $name === $activeModule ? 'tab-active' : '' ?>" href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => $name]) ?>">
|
||||
<a class="tab gap-2 <?= $name === $activeModule ? 'tab-active' : '' ?>" <?= $name === $activeModule ? 'aria-current="page"' : '' ?> href="<?= phpb_url('website_manager', ['tab' => 'ext--form', 'action' => $name]) ?>">
|
||||
<i class="ph-duotone <?= $icon ?>"></i>
|
||||
<?= $module['label'] ?>
|
||||
</a>
|
||||
@@ -47,6 +48,7 @@ if ($modules[$activeModule]['showTabs'] === true):
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
</nav>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
@@ -185,6 +185,20 @@
|
||||
}
|
||||
}
|
||||
@layer utilities {
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
border-width: 0;
|
||||
}
|
||||
.static {
|
||||
position: static;
|
||||
}
|
||||
.mx-auto {
|
||||
margin-inline: auto;
|
||||
}
|
||||
@@ -212,15 +226,15 @@
|
||||
.mb-4 {
|
||||
margin-bottom: calc(var(--spacing) * 4);
|
||||
}
|
||||
.mb-5 {
|
||||
margin-bottom: calc(var(--spacing) * 5);
|
||||
}
|
||||
.mb-6 {
|
||||
margin-bottom: calc(var(--spacing) * 6);
|
||||
}
|
||||
.ml-1 {
|
||||
margin-left: var(--spacing);
|
||||
}
|
||||
.ml-2 {
|
||||
margin-left: calc(var(--spacing) * 2);
|
||||
}
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
@@ -239,9 +253,6 @@
|
||||
.w-6 {
|
||||
width: calc(var(--spacing) * 6);
|
||||
}
|
||||
.w-12 {
|
||||
width: calc(var(--spacing) * 12);
|
||||
}
|
||||
.w-16 {
|
||||
width: calc(var(--spacing) * 16);
|
||||
}
|
||||
@@ -251,9 +262,18 @@
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.w-max {
|
||||
width: max-content;
|
||||
}
|
||||
.max-w-2xl {
|
||||
max-width: var(--container-2xl);
|
||||
}
|
||||
.min-w-40 {
|
||||
min-width: calc(var(--spacing) * 40);
|
||||
}
|
||||
.min-w-full {
|
||||
min-width: 100%;
|
||||
}
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
@@ -263,11 +283,20 @@
|
||||
.cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
.flex-col-reverse {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
.flex-wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
.items-start {
|
||||
align-items: flex-start;
|
||||
}
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
@@ -275,6 +304,9 @@
|
||||
.justify-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.justify-start {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.gap-1 {
|
||||
gap: var(--spacing);
|
||||
}
|
||||
@@ -284,6 +316,9 @@
|
||||
.gap-3 {
|
||||
gap: calc(var(--spacing) * 3);
|
||||
}
|
||||
.gap-4 {
|
||||
gap: calc(var(--spacing) * 4);
|
||||
}
|
||||
:where(.space-y-1 > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(var(--spacing) * var(--tw-space-y-reverse));
|
||||
@@ -304,6 +339,11 @@
|
||||
margin-block-start: calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
:where(.space-y-5 > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
.overflow-x-auto {
|
||||
overflow-x: auto;
|
||||
}
|
||||
@@ -324,6 +364,10 @@
|
||||
border-style: var(--tw-border-style);
|
||||
border-width: 2px;
|
||||
}
|
||||
.border-b {
|
||||
border-bottom-style: var(--tw-border-style);
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
.border-l-2 {
|
||||
border-left-style: var(--tw-border-style);
|
||||
border-left-width: 2px;
|
||||
@@ -341,18 +385,42 @@
|
||||
.p-3 {
|
||||
padding: calc(var(--spacing) * 3);
|
||||
}
|
||||
.px-0 {
|
||||
padding-inline: 0px;
|
||||
}
|
||||
.px-3 {
|
||||
padding-inline: calc(var(--spacing) * 3);
|
||||
}
|
||||
.px-4 {
|
||||
padding-inline: calc(var(--spacing) * 4);
|
||||
}
|
||||
.py-2 {
|
||||
padding-block: calc(var(--spacing) * 2);
|
||||
}
|
||||
.py-8 {
|
||||
padding-block: calc(var(--spacing) * 8);
|
||||
}
|
||||
.py-16 {
|
||||
padding-block: calc(var(--spacing) * 16);
|
||||
}
|
||||
.pl-4 {
|
||||
padding-left: calc(var(--spacing) * 4);
|
||||
.pt-2 {
|
||||
padding-top: calc(var(--spacing) * 2);
|
||||
}
|
||||
.pb-4 {
|
||||
padding-bottom: calc(var(--spacing) * 4);
|
||||
}
|
||||
.pl-3 {
|
||||
padding-left: calc(var(--spacing) * 3);
|
||||
}
|
||||
.pl-8 {
|
||||
padding-left: calc(var(--spacing) * 8);
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
.font-mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
@@ -403,14 +471,10 @@
|
||||
.uppercase {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.shadow {
|
||||
.shadow-sm {
|
||||
--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
.shadow-lg {
|
||||
--tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
.transition-colors {
|
||||
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||
@@ -419,6 +483,29 @@
|
||||
.active\:cursor-grabbing:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
@media (width >= 40rem) {
|
||||
.sm\:ml-2 {
|
||||
margin-left: calc(var(--spacing) * 2);
|
||||
}
|
||||
.sm\:min-w-28 {
|
||||
min-width: calc(var(--spacing) * 28);
|
||||
}
|
||||
.sm\:flex-row {
|
||||
flex-direction: row;
|
||||
}
|
||||
.sm\:items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.sm\:justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
.sm\:justify-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.sm\:pl-4 {
|
||||
padding-left: calc(var(--spacing) * 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@layer theme, base, components, utilities;
|
||||
@layer theme;
|
||||
|
||||
@@ -7,8 +7,8 @@ if ($id > 0):
|
||||
$fields = json_decode($form["fields"], true);
|
||||
?>
|
||||
|
||||
<div class="max-w-2xl mx-auto">
|
||||
<div x-data="{data: {fields : {}}, status: 'idle', submitted: false, errorMessage: ''}">
|
||||
<div class="mx-auto w-full max-w-2xl">
|
||||
<div x-data="{data: {fields : {}}, status: 'idle', submitted: false, errorMessage: ''}" class="space-y-4">
|
||||
<form x-show="!submitted" x-transition:leave x-transition:leave-opacity-0 x-on:submit.prevent="
|
||||
status = 'busy';
|
||||
errorMessage = '';
|
||||
@@ -40,82 +40,99 @@ if ($id > 0):
|
||||
? $field["options"]
|
||||
: [];
|
||||
?>
|
||||
<div class="form-control mb-4">
|
||||
<label class="label mb-1">
|
||||
<div class="form-control mb-5">
|
||||
<?php if ($fieldType === "checkbox" || $fieldType === "radio"): ?>
|
||||
<fieldset class="space-y-2">
|
||||
<legend class="label mb-1 px-0">
|
||||
<span class="label-text font-medium">
|
||||
<?= $fieldLabel ?>
|
||||
<?= phpb_e($fieldLabel) ?>
|
||||
<?php if ($fieldRequired): ?>
|
||||
<span class="text-error ml-1">*</span>
|
||||
<span class="ml-1 text-error" aria-hidden="true">*</span>
|
||||
<span class="sr-only">(required)</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</legend>
|
||||
<?php else: ?>
|
||||
<label for="form-field-<?= phpb_e($fieldName) ?>" class="label mb-1 px-0">
|
||||
<span class="label-text font-medium">
|
||||
<?= phpb_e($fieldLabel) ?>
|
||||
<?php if ($fieldRequired): ?>
|
||||
<span class="ml-1 text-error" aria-hidden="true">*</span>
|
||||
<span class="sr-only">(required)</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if ($fieldType === "select"): ?>
|
||||
<select x-model="data.fields.<?= $fieldName ?>" class="select select-bordered w-full" <?= $fieldRequired
|
||||
<select id="form-field-<?= phpb_e($fieldName) ?>" x-model="data.fields.<?= $fieldName ?>" class="select select-bordered w-full" <?= $fieldRequired
|
||||
? "required"
|
||||
: "" ?>>
|
||||
<option value="" disabled selected>Please select</option>
|
||||
<?php foreach ($fieldOptions as $option): ?>
|
||||
<option value="<?= $option[
|
||||
<option value="<?= phpb_e($option[
|
||||
"value"
|
||||
] ?>"><?= $option["label"] ?></option>
|
||||
]) ?>"><?= phpb_e($option["label"]) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php elseif ($fieldType === "checkbox"): ?>
|
||||
<div class="space-y-2">
|
||||
<?php foreach ($fieldOptions as $option): ?>
|
||||
<label class="label cursor-pointer gap-3">
|
||||
<span class="label-text"><?= $option[
|
||||
"label"
|
||||
] ?></span>
|
||||
<input type="checkbox" value="<?= $option[
|
||||
<label class="label cursor-pointer justify-start gap-3 rounded-box border border-base-300 px-3 py-2">
|
||||
<input type="checkbox" value="<?= phpb_e($option[
|
||||
"value"
|
||||
] ?>" x-model="data.fields.<?= $fieldName ?>" class="checkbox checkbox-sm checkbox-primary" />
|
||||
]) ?>" x-model="data.fields.<?= $fieldName ?>" class="checkbox checkbox-sm checkbox-primary" />
|
||||
<span class="label-text"><?= phpb_e($option[
|
||||
"label"
|
||||
]) ?></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif ($fieldType === "radio"): ?>
|
||||
<div class="space-y-2">
|
||||
<?php foreach ($fieldOptions as $option): ?>
|
||||
<label class="label cursor-pointer gap-3">
|
||||
<span class="label-text"><?= $option[
|
||||
"label"
|
||||
] ?></span>
|
||||
<input type="radio" name="<?= $fieldName ?>" value="<?= $option[
|
||||
<label class="label cursor-pointer justify-start gap-3 rounded-box border border-base-300 px-3 py-2">
|
||||
<input type="radio" name="<?= phpb_e($fieldName) ?>" value="<?= phpb_e($option[
|
||||
"value"
|
||||
] ?>" x-model="data.fields.<?= $fieldName ?>" class="radio radio-sm radio-primary" />
|
||||
]) ?>" x-model="data.fields.<?= $fieldName ?>" class="radio radio-sm radio-primary" />
|
||||
<span class="label-text"><?= phpb_e($option[
|
||||
"label"
|
||||
]) ?></span>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif ($fieldType === "textarea"): ?>
|
||||
<textarea x-model="data.fields.<?= $fieldName ?>" class="textarea textarea-bordered w-full" placeholder="<?= $fieldLabel ?>" <?= $fieldRequired
|
||||
<textarea id="form-field-<?= phpb_e($fieldName) ?>" x-model="data.fields.<?= $fieldName ?>" class="textarea textarea-bordered w-full" placeholder="<?= phpb_e($fieldLabel) ?>" <?= $fieldRequired
|
||||
? "required"
|
||||
: "" ?> rows="4"></textarea>
|
||||
<?php else: ?>
|
||||
<input type="<?= $fieldType ?>" x-model="data.fields.<?= $fieldName ?>" class="input input-bordered w-full" placeholder="<?= $fieldLabel ?>" <?= $fieldRequired
|
||||
<input id="form-field-<?= phpb_e($fieldName) ?>" type="<?= phpb_e($fieldType) ?>" x-model="data.fields.<?= $fieldName ?>" class="input input-bordered w-full" placeholder="<?= phpb_e($fieldLabel) ?>" <?= $fieldRequired
|
||||
? "required"
|
||||
: "" ?>>
|
||||
<?php endif; ?>
|
||||
<?php if ($fieldType === "checkbox" || $fieldType === "radio"): ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
<div class="mt-6">
|
||||
<button type="submit" class="btn btn-primary w-full" :disabled="status === 'busy'">
|
||||
<span x-show="status === 'idle'">
|
||||
<i class="ph-duotone ph-paper-plane-tilt"></i>
|
||||
<button type="submit" class="btn btn-primary w-full" :disabled="status === 'busy'" :aria-busy="status === 'busy'">
|
||||
<span x-show="status === 'idle'" aria-live="polite">
|
||||
<i class="ph-duotone ph-paper-plane-tilt" aria-hidden="true"></i>
|
||||
Submit
|
||||
</span>
|
||||
<span x-show="status === 'busy'">
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
<span x-show="status === 'busy'" role="status" aria-live="polite">
|
||||
<span class="loading loading-spinner loading-sm" aria-hidden="true"></span>
|
||||
Sending...
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div x-show="errorMessage" x-text="errorMessage" class="alert alert-error mt-4" role="alert"></div>
|
||||
<div x-show="submitted" x-transition:enter x-transition:enter-opacity-0 x-transition:enter-delay-100 class="card bg-base-100 shadow-lg mt-4">
|
||||
<div x-show="errorMessage" x-text="errorMessage" class="alert alert-error mt-4 shadow-sm" role="alert" aria-live="assertive" aria-atomic="true"></div>
|
||||
<div x-show="submitted" x-transition:enter x-transition:enter-opacity-0 x-transition:enter-delay-100 class="card mt-4 border border-success/30 bg-base-100 shadow-sm" role="status" aria-live="polite">
|
||||
<div class="card-body items-center text-center">
|
||||
<div class="w-16 h-16 rounded-full bg-success/20 flex items-center justify-center mb-2">
|
||||
<i class="ph-duotone ph-check text-3xl text-success"></i>
|
||||
<div class="mb-2 flex h-16 w-16 items-center justify-center rounded-full bg-success/20">
|
||||
<i class="ph-duotone ph-check text-3xl text-success" aria-hidden="true"></i>
|
||||
</div>
|
||||
<h3 class="card-title text-lg">Thank you!</h3>
|
||||
<p class="text-base-content/60">Your message has been sent successfully.</p>
|
||||
@@ -126,10 +143,10 @@ if ($id > 0):
|
||||
<?php
|
||||
else:
|
||||
?>
|
||||
<div class="form-wrapper max-w-2xl mx-auto">
|
||||
<div class="card bg-base-200 border-2 border-dashed border-base-300">
|
||||
<div class="card-body items-center text-center py-8">
|
||||
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30"></i>
|
||||
<div class="form-wrapper mx-auto w-full max-w-2xl">
|
||||
<div class="card border-2 border-dashed border-base-300 bg-base-200/50">
|
||||
<div class="card-body items-center py-8 text-center">
|
||||
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30" aria-hidden="true"></i>
|
||||
<p class="text-sm text-base-content/50 mt-2">Select a form in the settings</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user