mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Refactor: Form improvements and cleanup: note contextuel, annexes, fichiers
1. fix: form improvements — multiple promoteurices, asterisks, contact dedup, bentopdf - Multiple promoteurice (interne + ULB): both fieldsets now support dynamic add/remove rows (same pattern as lecteurs). field names changed to arrays (jury_promoteur[], jury_promoteur_ulb_name[]). Controllers accept both scalar and array forms for backwards compat. - ULB promoteurice: when finality=Approfondi, asterisk appears on legend and first ULB input is marked required (JS toggle). Non-Approfondi hides the fieldset and clears values. - Contact visibility duplication: removed redundant contact_public checkbox from admin add/edit forms (showContact=false). The 'mail' field in fieldset-tfe-info already serves this purpose. - Asterisk fixes: website URL field now has asterisk+required when Site web format selected. Video/audio already had correct required handling. - bentopdf link: clearer full URL 'https://bentopdf.com/' in both fichiers-fragment.php and form.php (edit mode) 2. refactor: merge Note contextuelle into Backoffice, add Lien BAIU, reorder fields Backoffice fieldset now contains in order: 1. Note contextuelle (was standalone fieldset) 2. Points du jury 3. Remarques 4. Lien BAIU (moved from Métadonnées complémentaires) 5. Exemplaire physique BAIU 6. Exemplaire physique ERG 7. Contact interne Métadonnées complémentaires now only has: pages, minutes, annexes checkbox. Removed dead showContextNote variable from form.php, add.php, edit.php. Controller baiu_link still mapped to input name "lien" (no migration needed). 3. refactor: move annexes checkbox from Métadonnées into Fichiers fieldset - Removed 'Ce TFE comporte des annexes' checkbox from fieldset-metadata.php. - Added annexes checkbox + conditional file input to fichiers-fragment.php. When checked, an HTMX swap reveals the 'annexes' file input (multiple, PDF or ZIP/TAR, max 500 MB). - form.php seeds ['has_annexes'] for initial fragment render. - Métadonnées complémentaires now only contains pages + minutes.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
*
|
||||
* Jury data:
|
||||
* ?string $juryPromoteur, $juryPromoteurUlb, $juryPresident
|
||||
* array $juryPromoteurs, $juryPromoteursUlb
|
||||
* array $lecteursInternes, $lecteursExternes
|
||||
* bool $showPresident, $showPromoteurUlb, $promoteurUlbConditional
|
||||
*
|
||||
@@ -31,8 +32,7 @@
|
||||
* bool $showContact — Contact checkbox fieldset
|
||||
* bool $showCoverPreview — cover image preview + remove checkbox
|
||||
* bool $showExistingFiles — existing thesis files list (sortable, deletable)
|
||||
* bool $showContextNote — Note contextuelle fieldset
|
||||
* bool $showBackoffice — Backoffice fieldset (jury_points, remarks, contact_interne, exemplaires)
|
||||
* bool $showBackoffice — Backoffice fieldset (context_note, jury_points, remarks, baiu_link, exemplaires, contact_interne)
|
||||
* bool $showEmailConfirmation — E-mail de confirmation fieldset
|
||||
* bool $showPublish — Publication checkbox fieldset
|
||||
* string $helpFn — fn(string $key): string (for help blocks)
|
||||
@@ -64,7 +64,9 @@ $formData = $formData ?? [];
|
||||
$synopsisExtra = $synopsisExtra ?? "";
|
||||
|
||||
$juryPromoteur = $juryPromoteur ?? null;
|
||||
$juryPromoteurs = $juryPromoteurs ?? [];
|
||||
$juryPromoteurUlb = $juryPromoteurUlb ?? null;
|
||||
$juryPromoteursUlb = $juryPromoteursUlb ?? [];
|
||||
$lecteursInternes = $lecteursInternes ?? [];
|
||||
$lecteursExternes = $lecteursExternes ?? [];
|
||||
$juryPresident = $juryPresident ?? null;
|
||||
@@ -85,7 +87,6 @@ $showContact = $showContact ?? false;
|
||||
$showCoverPreview = $showCoverPreview ?? false;
|
||||
$showExistingFiles = $showExistingFiles ?? false;
|
||||
$showBannerPreview = false; // Banners merged into covers — field removed
|
||||
$showContextNote = $showContextNote ?? false;
|
||||
$showBackoffice = $showBackoffice ?? false;
|
||||
$showEmailConfirmation = $showEmailConfirmation ?? false;
|
||||
$showPublish = $showPublish ?? false;
|
||||
@@ -239,38 +240,34 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
$helpContent = $helpFn("fieldset_files");
|
||||
include APP_ROOT . "/templates/partials/form/form-help-block.php";
|
||||
}
|
||||
// Temporarily populate $_POST so the fragment can read formats/website values.
|
||||
// Temporarily populate $_POST so the fragment can read formats/website/annexes values.
|
||||
$_savedPost = $_POST;
|
||||
$_POST['formats'] = $checkedFormatsForSiteWeb;
|
||||
$_POST['website_url'] = $existingWebsiteUrl;
|
||||
$_POST['website_label'] = $existingWebsiteLabel;
|
||||
$_POST['admin_mode'] = $adminMode ? '1' : '0';
|
||||
$_POST['has_annexes'] = $formData['has_annexes'] ?? null;
|
||||
include APP_ROOT . '/public/partage/fichiers-fragment.php';
|
||||
$_POST = $_savedPost;
|
||||
unset($_savedPost);
|
||||
?>
|
||||
<?php else: ?>
|
||||
<!-- Edit mode: Format checkboxes (old website fragment) + existing files management -->
|
||||
<fieldset>
|
||||
<legend>Format(s)</legend>
|
||||
<?php
|
||||
$name = "formats";
|
||||
$label = "Format(s) du TFE :";
|
||||
$options = $formatTypes;
|
||||
$checked = $formData["formats"] ?? [];
|
||||
$required = !$adminMode;
|
||||
$hxPost = "/admin/format-website-fragment.php";
|
||||
$hxTarget = "#edit-website-url-fieldset";
|
||||
$hxSwap = "outerHTML";
|
||||
$hxInclude = "this, #edit-website-url-fieldset";
|
||||
include APP_ROOT . "/templates/partials/form/checkbox-list.php";
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Fichiers (edit mode) ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Fichiers</legend>
|
||||
<!-- Edit mode: reuse the same Format + Fichiers HTMX fragment as add/partage -->
|
||||
<?php
|
||||
// Synthesise POST-like data so fichiers-fragment.php renders the initial state.
|
||||
$_savedPost = $_POST;
|
||||
$_POST['formats'] = $checkedFormatsForSiteWeb;
|
||||
$_POST['website_url'] = $existingWebsiteUrl;
|
||||
$_POST['website_label'] = $existingWebsiteLabel;
|
||||
$_POST['admin_mode'] = $adminMode ? '1' : '0';
|
||||
$_POST['has_annexes'] = $formData['has_annexes'] ?? null;
|
||||
include APP_ROOT . '/public/partage/fichiers-fragment.php';
|
||||
$_POST = $_savedPost;
|
||||
unset($_savedPost);
|
||||
?>
|
||||
|
||||
<!-- Edit-only: existing files management -->
|
||||
<div id="edit-existing-files-block">
|
||||
<!-- Cover image -->
|
||||
<div class="admin-form-group">
|
||||
<label>Image de couverture :</label>
|
||||
@@ -397,64 +394,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- New thesis files -->
|
||||
<div class="admin-form-group admin-files-fieldgroup">
|
||||
<label>Ajouter des fichiers du TFE :</label>
|
||||
<div class="admin-file-input">
|
||||
<input type="file" id="tfe-files-input"
|
||||
name="files[]" multiple
|
||||
accept=".pdf,.jpg,.jpeg,.png,.gif,.webp,.mp4,.webm,.mov,.ogv,.mp3,.ogg,.oga,.wav,.flac,.aac,.m4a,.zip,.tar,.gz,.vtt"
|
||||
class="tfe-file-picker">
|
||||
<small class="admin-file-hint">
|
||||
PDF (max 100 MB) · Images (JPG/PNG/GIF/WEBP) · ZIP/TAR (max 500 MB) · autres fichiers.
|
||||
PDFs trop lourds ? <a href="https://www.bentopdf.com" target="_blank" rel="noopener">bentopdf.com</a>
|
||||
</small>
|
||||
<ul id="tfe-file-queue" class="tfe-file-queue sortable-list" aria-label="Nouveaux fichiers (réordonnable)"></ul>
|
||||
<p id="tfe-file-queue-empty" class="tfe-queue-empty">Aucun nouveau fichier sélectionné.</p>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Website URL fieldset for edit mode — shown/hidden via HTMX -->
|
||||
<fieldset id="edit-website-url-fieldset" style="display:none">
|
||||
<legend>Site web</legend>
|
||||
<div class="admin-form-group">
|
||||
<label for="website_url">URL du site :</label>
|
||||
<div class="admin-file-input">
|
||||
<input type="url" id="website_url" name="website_url"
|
||||
value="<?= htmlspecialchars($existingWebsiteUrl) ?>"
|
||||
placeholder="https://mon-tfe.erg.be">
|
||||
<small>Si le TFE est un site web, entrez son URL ici. Il sera affiché comme un site embarqué sur la page du TFE.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-form-group">
|
||||
<label for="website_label">Légende :</label>
|
||||
<input type="text" id="website_label" name="website_label"
|
||||
value="<?= htmlspecialchars($existingWebsiteLabel) ?>"
|
||||
placeholder="Description du site (optionnel)"
|
||||
class="admin-file-label-input"
|
||||
style="max-width:400px;">
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
// Server-side: show website fieldset if Site web already checked
|
||||
$_stmt = Database::getInstance()
|
||||
->getConnection()
|
||||
->prepare("SELECT id FROM format_types WHERE name = ? LIMIT 1");
|
||||
$_stmt->execute(["Site web"]);
|
||||
$_siteWebId = $_stmt->fetchColumn();
|
||||
if (
|
||||
$_siteWebId &&
|
||||
in_array(
|
||||
(string) $_siteWebId,
|
||||
array_map("strval", $checkedFormatsForSiteWeb),
|
||||
true,
|
||||
)
|
||||
) {
|
||||
echo '<script>document.getElementById("edit-website-url-fieldset").style.display=""</script>';
|
||||
}
|
||||
?>
|
||||
</div><!-- #edit-existing-files-block -->
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- ═══════════════════ Métadonnées complémentaires ═══════════════════ -->
|
||||
@@ -471,11 +411,13 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
"/templates/partials/form/fieldset-licence-explanation.php";
|
||||
?>
|
||||
|
||||
<?php if ($showContextNote): ?>
|
||||
<!-- ═══════════════════ Note contextuelle ═══════════════════ -->
|
||||
<?php if ($showBackoffice): ?>
|
||||
<!-- ═══════════════════ Backoffice ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Note contextuelle</legend>
|
||||
<div>
|
||||
<legend>Backoffice</legend>
|
||||
|
||||
<!-- 1. Note contextuelle -->
|
||||
<div class="admin-form-group">
|
||||
<label for="context_note">Note contextuelle :</label>
|
||||
<div>
|
||||
<textarea id="context_note" name="context_note"
|
||||
@@ -486,16 +428,10 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
<small>Visible publiquement pour les TFE Interne ou Interdit. Max 1 500 caractères.</small>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showBackoffice): ?>
|
||||
<!-- ═══════════════════ Backoffice ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Backoffice</legend>
|
||||
|
||||
<!-- 2. Points du jury -->
|
||||
<div class="admin-form-group">
|
||||
<label for="jury_points">Points :</label>
|
||||
<label for="jury_points">Points du jury :</label>
|
||||
<input type="number" id="jury_points" name="jury_points"
|
||||
value="<?= htmlspecialchars(
|
||||
$currentRaw["jury_points"] ??
|
||||
@@ -505,6 +441,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
<small>Note du jury (interne, non visible publiquement).</small>
|
||||
</div>
|
||||
|
||||
<!-- 3. Remarques -->
|
||||
<div class="admin-form-group">
|
||||
<label for="remarks">Remarques :</label>
|
||||
<textarea id="remarks" name="remarks" rows="4"><?= htmlspecialchars(
|
||||
@@ -513,18 +450,14 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
<small>Notes internes (non visibles publiquement).</small>
|
||||
</div>
|
||||
|
||||
<div class="admin-form-group">
|
||||
<label for="contact_interne">Contact interne :</label>
|
||||
<input type="email" id="contact_interne" name="contact_interne"
|
||||
value="<?= htmlspecialchars(
|
||||
$currentRaw["contact_interne"] ??
|
||||
($formData["contact_interne"] ??
|
||||
($currentAuthorEmail ?? "")),
|
||||
) ?>"
|
||||
placeholder="ton.email@exemple.be">
|
||||
<small>Adresse de contact interne (non visible publiquement).</small>
|
||||
</div>
|
||||
<!-- 4. Lien BAIU -->
|
||||
<?php
|
||||
$name = 'lien'; $label = 'Lien BAIU :'; $value = $oldFn('lien');
|
||||
$type = 'url'; $placeholder = 'https://...'; $hint = '';
|
||||
include APP_ROOT . '/templates/partials/form/text-field.php';
|
||||
?>
|
||||
|
||||
<!-- 5. Exemplaire BAIU -->
|
||||
<div class="admin-form-group">
|
||||
<label class="admin-checkbox-label">
|
||||
<input type="checkbox" name="exemplaire_baiu" value="1"
|
||||
@@ -539,6 +472,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
<small>Case logistique : cocher si un exemplaire physique est disponible à la BAIU.</small>
|
||||
</div>
|
||||
|
||||
<!-- 6. Exemplaire ERG -->
|
||||
<div class="admin-form-group">
|
||||
<label class="admin-checkbox-label">
|
||||
<input type="checkbox" name="exemplaire_erg" value="1"
|
||||
@@ -552,6 +486,19 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
</label>
|
||||
<small>Case logistique : cocher si un exemplaire physique est disponible à l'ERG.</small>
|
||||
</div>
|
||||
|
||||
<!-- 7. Contact interne -->
|
||||
<div class="admin-form-group">
|
||||
<label for="contact_interne">Contact interne :</label>
|
||||
<input type="email" id="contact_interne" name="contact_interne"
|
||||
value="<?= htmlspecialchars(
|
||||
$currentRaw["contact_interne"] ??
|
||||
($formData["contact_interne"] ??
|
||||
($currentAuthorEmail ?? "")),
|
||||
) ?>"
|
||||
placeholder="ton.email@exemple.be">
|
||||
<small>Adresse de contact interne (non visible publiquement).</small>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user