mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-26 08:39:18 +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:
@@ -3,8 +3,10 @@
|
||||
* Jury composition fieldset partial.
|
||||
*
|
||||
* Variables consumed (all optional — defaults to empty/add-mode):
|
||||
* $juryPromoteur string|null Promoteur interne name
|
||||
* $juryPromoteurUlb string|null Promoteur ULB name
|
||||
* $juryPromoteur string|null Promoteur interne name (single or primary)
|
||||
* $juryPromoteurs array [{name: string}] Multiple promoteurs internes
|
||||
* $juryPromoteurUlb string|null Promoteur ULB name (single or primary)
|
||||
* $juryPromoteursUlb array [{name: string}] Multiple promoteurs ULB
|
||||
* $lecteursInternes array [{name: string}]
|
||||
* $lecteursExternes array [{name: string}]
|
||||
* $juryPresident string|null President name (edit-only, optional)
|
||||
@@ -16,7 +18,9 @@
|
||||
*/
|
||||
|
||||
$juryPromoteur = $juryPromoteur ?? null;
|
||||
$juryPromoteurs = $juryPromoteurs ?? [];
|
||||
$juryPromoteurUlb = $juryPromoteurUlb ?? null;
|
||||
$juryPromoteursUlb = $juryPromoteursUlb ?? [];
|
||||
$lecteursInternes = $lecteursInternes ?? [];
|
||||
$lecteursExternes = $lecteursExternes ?? [];
|
||||
$juryPresident = $juryPresident ?? null;
|
||||
@@ -44,36 +48,107 @@ if ($addMode && function_exists('old')) {
|
||||
<fieldset>
|
||||
<legend>Composition du jury</legend>
|
||||
|
||||
<!-- Promoteur·ice interne -->
|
||||
<div>
|
||||
<label for="jury_promoteur">Promoteur·ice interne :<?= $adminMode ? '' : ' <span class="asterisk">*</span>' ?></label>
|
||||
<input type="text" id="jury_promoteur" name="jury_promoteur"
|
||||
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>>
|
||||
</div>
|
||||
<!-- Promoteur·ice(s) interne -->
|
||||
<fieldset class="admin-jury-lecteurs">
|
||||
<legend>Promoteur·ice(s) interne<?= $adminMode ? '' : ' <span class="asterisk">*</span>' ?></legend>
|
||||
<div id="jury-promoteur-interne-list" class="admin-jury-list">
|
||||
<?php if (empty($juryPromoteurs) && $juryPromoteur === null): ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_promoteur[]" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>
|
||||
id="jury_promoteur" aria-label="Promoteur·ice interne 1 — nom">
|
||||
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
||||
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php elseif (!empty($juryPromoteurs)): ?>
|
||||
<?php foreach ($juryPromoteurs as $pi => $pm): ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_promoteur[]"
|
||||
value="<?= htmlspecialchars($pm['name']) ?>" placeholder="Nom"
|
||||
<?= (!$adminMode && $pi === 0) ? 'required' : '' ?>
|
||||
aria-label="Promoteur·ice interne <?= $pi + 1 ?> — nom">
|
||||
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
||||
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_promoteur[]"
|
||||
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom" <?= $adminMode ? '' : 'required' ?>
|
||||
aria-label="Promoteur·ice interne 1 — nom">
|
||||
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
||||
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<button type="button" class="btn btn--secondary admin-add-jury-btn"
|
||||
onclick="addJuryRow('jury-promoteur-interne-list', 'jury_promoteur', 'Promoteur·ice interne')">
|
||||
+ Ajouter un·e promoteur·ice interne
|
||||
</button>
|
||||
</fieldset>
|
||||
|
||||
<?php if ($showPromoteurUlb): ?>
|
||||
<!-- Promoteur·ice ULB -->
|
||||
<div id="jury-promoteur-ulb-row"<?= $promoteurUlbConditional ? ' style="display:none"' : '' ?>>
|
||||
<label for="jury_promoteur_ulb_name">Promoteur·ice ULB :</label>
|
||||
<input type="text" id="jury_promoteur_ulb_name" name="jury_promoteur_ulb_name"
|
||||
value="<?= htmlspecialchars($juryPromoteurUlb ?? '') ?>" placeholder="Nom">
|
||||
</div>
|
||||
<!-- Promoteur·ice(s) ULB -->
|
||||
<fieldset class="admin-jury-lecteurs" id="jury-promoteur-ulb-row"<?= $promoteurUlbConditional ? ' style="display:none"' : '' ?>>
|
||||
<legend>Promoteur·ice(s) ULB<span id="jury-ulb-asterisk" style="display:none"> <span class="asterisk">*</span></span></legend>
|
||||
<div id="jury-promoteur-ulb-list" class="admin-jury-list">
|
||||
<?php if (empty($juryPromoteursUlb) && $juryPromoteurUlb === null): ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_promoteur_ulb_name[]" placeholder="Nom"
|
||||
aria-label="Promoteur·ice ULB 1 — nom">
|
||||
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
||||
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php elseif (!empty($juryPromoteursUlb)): ?>
|
||||
<?php foreach ($juryPromoteursUlb as $pi => $pm): ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_promoteur_ulb_name[]"
|
||||
value="<?= htmlspecialchars($pm['name']) ?>" placeholder="Nom"
|
||||
aria-label="Promoteur·ice ULB <?= $pi + 1 ?> — nom">
|
||||
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
||||
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_promoteur_ulb_name[]"
|
||||
value="<?= htmlspecialchars($juryPromoteurUlb ?? '') ?>" placeholder="Nom"
|
||||
aria-label="Promoteur·ice ULB 1 — nom">
|
||||
<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"
|
||||
onclick="removeJuryRow(this)" aria-label="Supprimer"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<button type="button" class="btn btn--secondary admin-add-jury-btn"
|
||||
onclick="addJuryRow('jury-promoteur-ulb-list', 'jury_promoteur_ulb_name', 'Promoteur·ice ULB')">
|
||||
+ Ajouter un·e promoteur·ice ULB
|
||||
</button>
|
||||
</fieldset>
|
||||
<?php if ($promoteurUlbConditional): ?>
|
||||
<script>
|
||||
(function() {
|
||||
var finalitySelect = document.querySelector('select[name="finality"]');
|
||||
var ulbRow = document.getElementById('jury-promoteur-ulb-row');
|
||||
var ulbInput = ulbRow ? ulbRow.querySelector('input') : null;
|
||||
function toggleUlb() {
|
||||
if (!finalitySelect || !ulbRow) return;
|
||||
var ulbAsterisk = document.getElementById('jury-ulb-asterisk');
|
||||
function isApprofondiSelected() {
|
||||
if (!finalitySelect) return false;
|
||||
var selected = finalitySelect.options[finalitySelect.selectedIndex];
|
||||
var text = (selected && selected.text) ? selected.text.toLowerCase() : '';
|
||||
var isApprofondi = text.includes('approfondi');
|
||||
ulbRow.style.display = isApprofondi ? '' : 'none';
|
||||
if (ulbInput) {
|
||||
ulbInput.required = <?= $adminMode ? 'false' : 'isApprofondi' ?>;
|
||||
ulbInput.disabled = !isApprofondi;
|
||||
if (!isApprofondi) ulbInput.value = '';
|
||||
return text.includes('approfondi');
|
||||
}
|
||||
function toggleUlb() {
|
||||
if (!ulbRow) return;
|
||||
var show = isApprofondiSelected();
|
||||
ulbRow.style.display = show ? '' : 'none';
|
||||
if (ulbAsterisk) ulbAsterisk.style.display = show ? '' : 'none';
|
||||
// Mark first ULB input required when finality is Approfondi
|
||||
if (ulbRow) {
|
||||
var inputs = ulbRow.querySelectorAll('input[name="jury_promoteur_ulb_name[]"]');
|
||||
inputs.forEach(function(inp, idx) {
|
||||
inp.required = <?= $adminMode ? 'false' : 'show && idx === 0' ?>;
|
||||
inp.disabled = !show;
|
||||
if (!show) inp.value = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
if (finalitySelect) {
|
||||
|
||||
Reference in New Issue
Block a user