Dev #8

Merged
deepDiverPaul merged 14 commits from dev into main 2026-11-26 09:04:24 +00:00
8 changed files with 231 additions and 120 deletions
Showing only changes of commit 151ac9df4c - Show all commits
+2 -1
View File
@@ -17,7 +17,8 @@ cache
uploads uploads
extensions/dev_* extensions/dev_*
docs docs
docs/* .agents
skills-lock.json
# Editor directories and files # Editor directories and files
.vscode/* .vscode/*
@@ -21,7 +21,7 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
<div class="mb-6"> <div class="mb-6">
<div class="flex items-center gap-3"> <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> <i class="ph-duotone ph-arrow-left text-xl"></i>
</a> </a>
<div> <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'].'">'; 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="card-body">
<div class="flex items-center gap-2 mb-4"> <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> <h3 class="card-title text-lg">Basics</h3>
</div> </div>
<div class="form-control"> <div class="form-control">
<label class="label"> <label class="label" for="form-name">
<span class="label-text font-medium">Form name</span> <span class="label-text font-medium">Form name</span>
</label> </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> <span class="label-text-alt text-base-content/60">A unique name for your form.</span>
</div> </div>
</div> </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="card-body">
<div class="flex items-center gap-2 mb-4"> <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> <h3 class="card-title text-lg">Form fields</h3>
</div> </div>
<p class="text-sm text-base-content/60 mb-4">Define the fields users can fill out.</p> <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)"> <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> <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> <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>
<div x-show="fields.length > 0" class="space-y-3"> <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)" @drop.prevent="moveField(dragIndex, index)"
@dragend="dragIndex = null" @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 --> <!-- 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> <i class="ph-duotone ph-dots-six-vertical text-lg"></i>
</button> </button>
<span class="text-xs font-mono text-base-content/40 w-6">#[<span x-text="index + 1"></span>]</span> <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 <input
type="text" type="text"
x-model="field.name" 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 input-bordered input-sm w-full"
:class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Field name'))}" :class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Field name'))}"
/> />
</div> </div>
<div class="flex-1"> <div class="w-full flex-1">
<input <input
type="text" type="text"
x-model="field.label" x-model="field.label"
placeholder="Label" placeholder="Label"
:aria-label="'Field ' + (index + 1) + ' label'"
class="input input-bordered input-sm w-full" class="input input-bordered input-sm w-full"
:class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Label'))}" :class="{'input-error': getValidationErrors(field, index).some(e => e.includes('Label'))}"
/> />
</div> </div>
</div> </div>
<!-- Validation errors --> <!-- 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)"> <template x-for="(error, errIndex) in getValidationErrors(field, index)">
<div :key="errIndex" class="flex items-center gap-1"> <div :key="errIndex" class="flex items-center gap-1">
<i class="ph-duotone ph-warning text-sm"></i> <i class="ph-duotone ph-warning text-sm"></i>
@@ -185,8 +187,8 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</div> </div>
</template> </template>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex flex-wrap items-center gap-2">
<select x-model="field.type" class="select select-bordered select-sm flex-1"> <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="text">Text</option>
<option value="email">Email</option> <option value="email">Email</option>
<option value="textarea">Text area</option> <option value="textarea">Text area</option>
@@ -196,27 +198,27 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</select> </select>
<label class="label cursor-pointer gap-2"> <label class="label cursor-pointer gap-2">
<span class="label-text text-sm">Required</span> <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> </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> <i class="ph-duotone ph-trash"></i>
</button> </button>
</div> </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"> <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> <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> <i class="ph-duotone ph-plus"></i>
Add Add
</a> </button>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<template x-for="(option, optIndex) in field.options"> <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> <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.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 flex-1" /> <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"> <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> <i class="ph-duotone ph-x"></i>
</button> </button>
</div> </div>
@@ -228,28 +230,28 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</div> </div>
<div class="mt-4"> <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> <i class="ph-duotone ph-plus"></i>
Add field Add field
</a> </button>
</div> </div>
</div> </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="card-body">
<div class="flex items-center gap-2 mb-4"> <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> <h3 class="card-title text-lg">Actions</h3>
</div> </div>
<p class="text-sm text-base-content/60 mb-4">What should happen when a form is submitted?</p> <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)"> <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> <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> <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>
<div x-show="finishers.length > 0" class="space-y-2"> <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="p-3 border border-base-300 rounded-lg bg-base-200/50 space-y-3">
<div class="flex items-center gap-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> <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"> <template x-for="(definition, type) in finisherDefinitions" :key="type">
<option :value="type" x-text="definition.label"></option> <option :value="type" x-text="definition.label"></option>
</template> </template>
</select> </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> <i class="ph-duotone ph-trash"></i>
</button> </button>
</div> </div>
<div x-show="getFinisherSettings(finisher.type).length > 0" class="space-y-3 pl-8"> <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"> <template x-for="setting in getFinisherSettings(finisher.type)" :key="setting.name">
<div class="form-control"> <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'"> <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> <option value="">Select an email field</option>
<template x-for="field in fields.filter(field => field.type === 'email')" :key="field.name"> <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> <option :value="field.name" x-text="field.label + ' (' + field.name + ')' "></option>
@@ -279,17 +281,17 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</select> </select>
</template> </template>
<template x-if="setting.type === 'select'"> <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"> <template x-for="option in setting.options || []" :key="option.value">
<option :value="option.value" x-text="option.label"></option> <option :value="option.value" x-text="option.label"></option>
</template> </template>
</select> </select>
</template> </template>
<template x-if="setting.type === 'textarea'"> <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>
<template x-if="!['emailField', 'select', 'textarea'].includes(setting.type)"> <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> </template>
<span x-show="setting.help" class="label-text-alt text-base-content/60 mt-1" x-text="setting.help"></span> <span x-show="setting.help" class="label-text-alt text-base-content/60 mt-1" x-text="setting.help"></span>
</div> </div>
@@ -301,19 +303,19 @@ $isEditing = isset($form['id']) && $form['id'] > 0;
</div> </div>
<div class="mt-4"> <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> <i class="ph-duotone ph-plus"></i>
Add action Add action
</a> </button>
</div> </div>
</div> </div>
</div> </div>
<div class="flex justify-end gap-2"> <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"> <a href="?tab=ext--form" class="btn btn-ghost btn-sm sm:min-w-28">
Cancel Cancel
</a> </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> <i class="ph-duotone ph-floppy-disk"></i>
Save Save
</button> </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="card-body">
<div class="flex items-center gap-2 mb-4"> <div class="flex items-start gap-3 border-b border-base-300/60 pb-4">
<i class="ph-duotone ph-gear text-2xl text-base-content/60"></i> <i class="ph-duotone ph-gear mt-1 text-2xl text-primary" aria-hidden="true"></i>
<h3 class="card-title text-lg">Settings</h3> <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>
<div class="space-y-4"> <div class="space-y-5 pt-2">
<?php <?php
foreach (\Plugi\Extensions::getSettings('form') as $setting) { foreach (\Plugi\Extensions::getSettings('form') as $setting) {
phpb_render_setting($setting); phpb_render_setting($setting);
@@ -13,4 +15,4 @@
?> ?>
</div> </div>
</div> </div>
</div> </section>
@@ -15,7 +15,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
<div class="mb-6"> <div class="mb-6">
<div class="flex items-center gap-3"> <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> <i class="ph-duotone ph-arrow-left text-xl"></i>
</a> </a>
<div> <div>
@@ -26,7 +26,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
</div> </div>
<?php if (empty($entries)): ?> <?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"> <div class="card-body items-center text-center py-16">
<i class="ph-duotone ph-inbox text-6xl text-base-content/20"></i> <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> <h3 class="card-title text-lg mt-4">No submissions yet</h3>
@@ -34,7 +34,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
</div> </div>
</div> </div>
<?php else: ?> <?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="card-body p-0">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="table w-full"> <table class="table w-full">
@@ -45,7 +45,7 @@ $entries = $entriesRepository->findWhere('formId', $id);
<?php foreach ($fields as $field): ?> <?php foreach ($fields as $field): ?>
<th><?= phpb_e($field['label']) ?></th> <th><?= phpb_e($field['label']) ?></th>
<?php endforeach; ?> <?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> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -71,8 +71,8 @@ $entries = $entriesRepository->findWhere('formId', $id);
<td class="text-sm"><?= phpb_e($fieldValue) ?></td> <td class="text-sm"><?= phpb_e($fieldValue) ?></td>
<?php endforeach; ?> <?php endforeach; ?>
<td> <td>
<div class="flex justify-center"> <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') ?>"> <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> <i class="ph-duotone ph-trash text-lg"></i>
</a> </a>
</div> </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> <div>
<h2 class="text-xl font-bold">Forms</h2> <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> <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> </div>
<?php if (empty($forms)): ?> <?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"> <div class="card-body items-center text-center py-16">
<i class="ph-duotone ph-notebook text-6xl text-base-content/20"></i> <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> <h3 class="card-title text-lg mt-4">No forms yet</h3>
@@ -30,7 +30,7 @@ $forms = $formsRepository->getAll();
</div> </div>
</div> </div>
<?php else: ?> <?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="card-body p-0">
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<table class="table w-full"> <table class="table w-full">
@@ -38,7 +38,7 @@ $forms = $formsRepository->getAll();
<tr class="bg-base-200/50"> <tr class="bg-base-200/50">
<th class="w-16">ID</th> <th class="w-16">ID</th>
<th><?= phpb_trans('website-manager.name') ?></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> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -49,14 +49,14 @@ $forms = $formsRepository->getAll();
<div class="font-medium"><?= phpb_e($form['name']) ?></div> <div class="font-medium"><?= phpb_e($form['name']) ?></div>
</td> </td>
<td> <td>
<div class="flex items-center justify-center gap-1"> <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"> <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> <i class="ph-duotone ph-eye text-lg"></i>
</a> </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> <i class="ph-duotone ph-pencil-line text-lg"></i>
</a> </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> <i class="ph-duotone ph-trash text-lg"></i>
</a> </a>
</div> </div>
+4 -2
View File
@@ -33,13 +33,14 @@ if (isset($_GET['action']) && array_key_exists($_GET['action'], $modules)) $acti
<?php <?php
if ($modules[$activeModule]['showTabs'] === true): 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 <?php
foreach ($modules as $name => $module): foreach ($modules as $name => $module):
if ($module['inMenu'] === false) continue; if ($module['inMenu'] === false) continue;
$icon = $module['icon'] ?? 'ph-circle'; $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> <i class="ph-duotone <?= $icon ?>"></i>
<?= $module['label'] ?> <?= $module['label'] ?>
</a> </a>
@@ -47,6 +48,7 @@ if ($modules[$activeModule]['showTabs'] === true):
endforeach; endforeach;
?> ?>
</div> </div>
</nav>
<?php <?php
endif; endif;
?> ?>
+102 -15
View File
@@ -185,6 +185,20 @@
} }
} }
@layer utilities { @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 { .mx-auto {
margin-inline: auto; margin-inline: auto;
} }
@@ -212,15 +226,15 @@
.mb-4 { .mb-4 {
margin-bottom: calc(var(--spacing) * 4); margin-bottom: calc(var(--spacing) * 4);
} }
.mb-5 {
margin-bottom: calc(var(--spacing) * 5);
}
.mb-6 { .mb-6 {
margin-bottom: calc(var(--spacing) * 6); margin-bottom: calc(var(--spacing) * 6);
} }
.ml-1 { .ml-1 {
margin-left: var(--spacing); margin-left: var(--spacing);
} }
.ml-2 {
margin-left: calc(var(--spacing) * 2);
}
.flex { .flex {
display: flex; display: flex;
} }
@@ -239,9 +253,6 @@
.w-6 { .w-6 {
width: calc(var(--spacing) * 6); width: calc(var(--spacing) * 6);
} }
.w-12 {
width: calc(var(--spacing) * 12);
}
.w-16 { .w-16 {
width: calc(var(--spacing) * 16); width: calc(var(--spacing) * 16);
} }
@@ -251,9 +262,18 @@
.w-full { .w-full {
width: 100%; width: 100%;
} }
.w-max {
width: max-content;
}
.max-w-2xl { .max-w-2xl {
max-width: var(--container-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 {
flex: 1; flex: 1;
} }
@@ -263,11 +283,20 @@
.cursor-pointer { .cursor-pointer {
cursor: pointer; cursor: pointer;
} }
.flex-col {
flex-direction: column;
}
.flex-col-reverse {
flex-direction: column-reverse;
}
.flex-wrap {
flex-wrap: wrap;
}
.items-center { .items-center {
align-items: center; align-items: center;
} }
.justify-between { .items-start {
justify-content: space-between; align-items: flex-start;
} }
.justify-center { .justify-center {
justify-content: center; justify-content: center;
@@ -275,6 +304,9 @@
.justify-end { .justify-end {
justify-content: flex-end; justify-content: flex-end;
} }
.justify-start {
justify-content: flex-start;
}
.gap-1 { .gap-1 {
gap: var(--spacing); gap: var(--spacing);
} }
@@ -284,6 +316,9 @@
.gap-3 { .gap-3 {
gap: calc(var(--spacing) * 3); gap: calc(var(--spacing) * 3);
} }
.gap-4 {
gap: calc(var(--spacing) * 4);
}
:where(.space-y-1 > :not(:last-child)) { :where(.space-y-1 > :not(:last-child)) {
--tw-space-y-reverse: 0; --tw-space-y-reverse: 0;
margin-block-start: calc(var(--spacing) * var(--tw-space-y-reverse)); 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-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))); 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 {
overflow-x: auto; overflow-x: auto;
} }
@@ -324,6 +364,10 @@
border-style: var(--tw-border-style); border-style: var(--tw-border-style);
border-width: 2px; border-width: 2px;
} }
.border-b {
border-bottom-style: var(--tw-border-style);
border-bottom-width: 1px;
}
.border-l-2 { .border-l-2 {
border-left-style: var(--tw-border-style); border-left-style: var(--tw-border-style);
border-left-width: 2px; border-left-width: 2px;
@@ -341,18 +385,42 @@
.p-3 { .p-3 {
padding: calc(var(--spacing) * 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 { .py-8 {
padding-block: calc(var(--spacing) * 8); padding-block: calc(var(--spacing) * 8);
} }
.py-16 { .py-16 {
padding-block: calc(var(--spacing) * 16); padding-block: calc(var(--spacing) * 16);
} }
.pl-4 { .pt-2 {
padding-left: calc(var(--spacing) * 4); 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-center {
text-align: center; text-align: center;
} }
.text-right {
text-align: right;
}
.font-mono { .font-mono {
font-family: var(--font-mono); font-family: var(--font-mono);
} }
@@ -403,14 +471,10 @@
.uppercase { .uppercase {
text-transform: 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)); --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); 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-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-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)); transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
@@ -419,6 +483,29 @@
.active\:cursor-grabbing:active { .active\:cursor-grabbing:active {
cursor: grabbing; 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, base, components, utilities;
@layer theme; @layer theme;
@@ -7,8 +7,8 @@ if ($id > 0):
$fields = json_decode($form["fields"], true); $fields = json_decode($form["fields"], true);
?> ?>
<div class="max-w-2xl mx-auto"> <div class="mx-auto w-full max-w-2xl">
<div x-data="{data: {fields : {}}, status: 'idle', submitted: false, errorMessage: ''}"> <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=" <form x-show="!submitted" x-transition:leave x-transition:leave-opacity-0 x-on:submit.prevent="
status = 'busy'; status = 'busy';
errorMessage = ''; errorMessage = '';
@@ -40,82 +40,99 @@ if ($id > 0):
? $field["options"] ? $field["options"]
: []; : [];
?> ?>
<div class="form-control mb-4"> <div class="form-control mb-5">
<label class="label mb-1"> <?php if ($fieldType === "checkbox" || $fieldType === "radio"): ?>
<fieldset class="space-y-2">
<legend class="label mb-1 px-0">
<span class="label-text font-medium"> <span class="label-text font-medium">
<?= $fieldLabel ?> <?= phpb_e($fieldLabel) ?>
<?php if ($fieldRequired): ?> <?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; ?> <?php endif; ?>
</span> </span>
</label> </label>
<?php endif; ?>
<?php if ($fieldType === "select"): ?> <?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" ? "required"
: "" ?>> : "" ?>>
<option value="" disabled selected>Please select</option> <option value="" disabled selected>Please select</option>
<?php foreach ($fieldOptions as $option): ?> <?php foreach ($fieldOptions as $option): ?>
<option value="<?= $option[ <option value="<?= phpb_e($option[
"value" "value"
] ?>"><?= $option["label"] ?></option> ]) ?>"><?= phpb_e($option["label"]) ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<?php elseif ($fieldType === "checkbox"): ?> <?php elseif ($fieldType === "checkbox"): ?>
<div class="space-y-2"> <div class="space-y-2">
<?php foreach ($fieldOptions as $option): ?> <?php foreach ($fieldOptions as $option): ?>
<label class="label cursor-pointer gap-3"> <label class="label cursor-pointer justify-start gap-3 rounded-box border border-base-300 px-3 py-2">
<span class="label-text"><?= $option[ <input type="checkbox" value="<?= phpb_e($option[
"label"
] ?></span>
<input type="checkbox" value="<?= $option[
"value" "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> </label>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<?php elseif ($fieldType === "radio"): ?> <?php elseif ($fieldType === "radio"): ?>
<div class="space-y-2"> <div class="space-y-2">
<?php foreach ($fieldOptions as $option): ?> <?php foreach ($fieldOptions as $option): ?>
<label class="label cursor-pointer gap-3"> <label class="label cursor-pointer justify-start gap-3 rounded-box border border-base-300 px-3 py-2">
<span class="label-text"><?= $option[ <input type="radio" name="<?= phpb_e($fieldName) ?>" value="<?= phpb_e($option[
"label"
] ?></span>
<input type="radio" name="<?= $fieldName ?>" value="<?= $option[
"value" "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> </label>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<?php elseif ($fieldType === "textarea"): ?> <?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" ? "required"
: "" ?> rows="4"></textarea> : "" ?> rows="4"></textarea>
<?php else: ?> <?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" ? "required"
: "" ?>> : "" ?>>
<?php endif; ?> <?php endif; ?>
<?php if ($fieldType === "checkbox" || $fieldType === "radio"): ?>
</fieldset>
<?php endif; ?>
</div> </div>
<?php <?php
endforeach; ?> endforeach; ?>
<div class="mt-6"> <div class="mt-6">
<button type="submit" class="btn btn-primary w-full" :disabled="status === 'busy'"> <button type="submit" class="btn btn-primary w-full" :disabled="status === 'busy'" :aria-busy="status === 'busy'">
<span x-show="status === 'idle'"> <span x-show="status === 'idle'" aria-live="polite">
<i class="ph-duotone ph-paper-plane-tilt"></i> <i class="ph-duotone ph-paper-plane-tilt" aria-hidden="true"></i>
Submit Submit
</span> </span>
<span x-show="status === 'busy'"> <span x-show="status === 'busy'" role="status" aria-live="polite">
<span class="loading loading-spinner loading-sm"></span> <span class="loading loading-spinner loading-sm" aria-hidden="true"></span>
Sending... Sending...
</span> </span>
</button> </button>
</div> </div>
</form> </form>
<div x-show="errorMessage" x-text="errorMessage" class="alert alert-error mt-4" role="alert"></div> <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 bg-base-100 shadow-lg mt-4"> <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="card-body items-center text-center">
<div class="w-16 h-16 rounded-full bg-success/20 flex items-center justify-center mb-2"> <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"></i> <i class="ph-duotone ph-check text-3xl text-success" aria-hidden="true"></i>
</div> </div>
<h3 class="card-title text-lg">Thank you!</h3> <h3 class="card-title text-lg">Thank you!</h3>
<p class="text-base-content/60">Your message has been sent successfully.</p> <p class="text-base-content/60">Your message has been sent successfully.</p>
@@ -126,10 +143,10 @@ if ($id > 0):
<?php <?php
else: else:
?> ?>
<div class="form-wrapper max-w-2xl mx-auto"> <div class="form-wrapper mx-auto w-full max-w-2xl">
<div class="card bg-base-200 border-2 border-dashed border-base-300"> <div class="card border-2 border-dashed border-base-300 bg-base-200/50">
<div class="card-body items-center text-center py-8"> <div class="card-body items-center py-8 text-center">
<i class="ph-duotone ph-plus-circle text-4xl text-base-content/30"></i> <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> <p class="text-sm text-base-content/50 mt-2">Select a form in the settings</p>
</div> </div>
</div> </div>