Files
xamxam/app/templates/partials/form/jury-fieldset.php
Pontoporeia 696259afae Fix form field required states & missing fields per spec
- Admin add: add contact_public checkbox (matching edit form)
- All forms: formats checkbox-list now required
- All forms: jury promoteur·ice interne required, lecteur·ice interne/externe required
- All forms: licence select now required
- Admin edit: add E-mail de confirmation fieldset
- Partage: contact always visible when provided (no contact_public field)
- Partage: filter PACS from AP programs dropdown
- Server-side validation: formats, jury, licence required (create + edit controllers)
- Autofocus mappings for new validation errors
- No duplicate asterisks — verified across all rendered fields
- fix: add missing old() function in admin edit controller
- refactor: move admin email field to Backoffice as Contact interne, never send email
- Untrack admin.log (covered by .gitignore)
2026-05-07 23:39:41 +02:00

176 lines
8.3 KiB
PHP

<?php
/**
* 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
* $lecteursInternes array [{name: string}]
* $lecteursExternes array [{name: string}]
* $juryPresident string|null President name (edit-only, optional)
* $showPresident bool Show president field (default: false)
* $showPromoteurUlb bool Show ULB promoteur field (default: true)
* $promoteurUlbConditional bool If true, field is hidden unless finality=Approfondi
*
* In add-mode repopulation: if old() exists and values are null, populate from it.
*/
$juryPromoteur = $juryPromoteur ?? null;
$juryPromoteurUlb = $juryPromoteurUlb ?? null;
$lecteursInternes = $lecteursInternes ?? [];
$lecteursExternes = $lecteursExternes ?? [];
$juryPresident = $juryPresident ?? null;
$showPresident = $showPresident ?? false;
$showPromoteurUlb = $showPromoteurUlb ?? true;
$promoteurUlbConditional = $promoteurUlbConditional ?? false;
// Add-mode repopulation from flash data
$addMode = ($juryPromoteur === null && $juryPromoteurUlb === null && empty($lecteursInternes) && empty($lecteursExternes) && $juryPresident === null);
if ($addMode && function_exists('old')) {
$juryPromoteur = old('jury_promoteur') ?: null;
$juryPromoteurUlb = old('jury_promoteur_ulb_name') ?: null;
$juryPresident = old('jury_president') ?: null;
for ($i = 0; $i < 10; $i++) {
$n = old("jury_lecteur_interne:$i");
if ($n !== '') $lecteursInternes[] = ['name' => $n];
}
for ($i = 0; $i < 10; $i++) {
$n = old("jury_lecteur_externe:$i");
if ($n !== '') $lecteursExternes[] = ['name' => $n];
}
}
?>
<fieldset>
<legend>Composition du jury</legend>
<!-- Promoteur·ice interne -->
<div>
<label for="jury_promoteur">Promoteur·ice interne : <span class="asterisk">*</span></label>
<input type="text" id="jury_promoteur" name="jury_promoteur"
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom" required>
</div>
<?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>
<?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 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 = isApprofondi;
ulbInput.disabled = !isApprofondi;
if (!isApprofondi) ulbInput.value = '';
}
}
if (finalitySelect) {
finalitySelect.addEventListener('change', toggleUlb);
toggleUlb();
}
})();
</script>
<?php endif; ?>
<?php endif; ?>
<!-- Lecteur·ice(s) interne -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ice(s) interne <span class="asterisk">*</span></legend>
<div id="jury-lecteurs-internes-list" class="admin-jury-list">
<?php if (empty($lecteursInternes)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_interne[]" placeholder="Nom" required
aria-label="Lecteur·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 else: ?>
<?php foreach ($lecteursInternes as $li => $lm): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_interne[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
<?= $li === 0 ? 'required' : '' ?>
aria-label="Lecteur·ice interne <?= $li + 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 endif; ?>
</div>
<button type="button" class="btn btn--secondary admin-add-jury-btn"
onclick="addJuryRow('jury-lecteurs-internes-list', 'jury_lecteur_interne[]', 'Lecteur·ice interne')">
+ Ajouter un·e lecteur·ice interne
</button>
</fieldset>
<!-- Lecteur·ice(s) externe -->
<fieldset class="admin-jury-lecteurs">
<legend>Lecteur·ice(s) externe <span class="asterisk">*</span></legend>
<div id="jury-lecteurs-externes-list" class="admin-jury-list">
<?php if (empty($lecteursExternes)): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_externe[]" placeholder="Nom" required
aria-label="Lecteur·ice externe 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 else: ?>
<?php foreach ($lecteursExternes as $li => $lm): ?>
<div class="admin-jury-entry">
<input type="text" name="jury_lecteur_externe[]"
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
<?= $li === 0 ? 'required' : '' ?>
aria-label="Lecteur·ice externe <?= $li + 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 endif; ?>
</div>
<button type="button" class="btn btn--secondary admin-add-jury-btn"
onclick="addJuryRow('jury-lecteurs-externes-list', 'jury_lecteur_externe[]', 'Lecteur·ice externe')">
+ Ajouter un·e lecteur·ice externe
</button>
</fieldset>
<?php if ($showPresident): ?>
<!-- Président·e (admin edit only) -->
<div>
<label for="jury_president">Président·e :</label>
<input type="text" id="jury_president" name="jury_president"
value="<?= htmlspecialchars($juryPresident ?? '') ?>"
placeholder="Nom du/de la président·e (interne)">
</div>
<?php endif; ?>
</fieldset>
<script>
function addJuryRow(listId, inputName, roleLabel) {
var list = document.getElementById(listId);
if (!list) return;
var n = list.querySelectorAll('.admin-jury-entry').length + 1;
var div = document.createElement('div');
div.className = 'admin-jury-entry';
div.innerHTML = '<input type="text" name="' + inputName + '" placeholder="Nom"'
+ ' aria-label="' + roleLabel + ' ' + n + ' \u2014 nom">'
+ '<button type="button" class="btn btn--sm btn--ghost admin-btn-remove"'
+ ' onclick="removeJuryRow(this)" aria-label="Supprimer">'
+ '<span aria-hidden="true">\u2715</span></button>';
list.appendChild(div);
}
function removeJuryRow(btn) {
btn.closest('.admin-jury-entry').remove();
}
</script>