refactor form structure per new spec + fix

- split jury into interne/externe/ULB,
- remove president from student form,
- add language_autre,
- split duration into pages+minutes+annexes,
- move licence to degrés d'ouverture with CC2r,
- add license_custom,
- filter PACS from student AP list,
- editable généralités help block,
- Libre toggle per settings

Fix:
- missing comma after cc4r column in schema.sql
- remove duplicate form footer from partage template
- remove couverture from student files fieldset; add promoteur ULB conditional disable via JS on Approfondi
- promoteur ULB: remove 'si applicable', make required when visible
This commit is contained in:
Pontoporeia
2026-05-07 17:52:46 +02:00
parent dce0e0b301
commit 24d68dda59
21 changed files with 694 additions and 381 deletions

View File

@@ -2,62 +2,48 @@
/**
* Shared partial — "Métadonnées complémentaires" fieldset.
*
* Now split: licence/access moved to licence-explanation fieldset.
* This fieldset keeps: duration (pages + minutes), lien (external link).
*
* Variables consumed:
* callable|null $oldFn — callable($key, $default='') for old/current values.
* callable|null $withAutofocusFn — callable($field, $attrs=[]) to inject autofocus.
* array $licenseTypes — options for the license select.
* array $enabledAccessTypes — raw access-type rows (with 'id', 'name', optionally 'description').
* array $formData — raw form data (used for selected state).
* int $defaultAccessTypeId — default access type id; defaults to 2.
* bool $showDescription — when true, appends description to access-type option labels.
* array $formData — raw form data (used for repopulation).
*/
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
$withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs;
$formData = $formData ?? [];
$defaultAccessTypeId = $defaultAccessTypeId ?? 2;
$showDescription = $showDescription ?? false;
$accessOptions = array_map(function ($at) use ($showDescription) {
$label = $at['name'];
if ($showDescription && !empty($at['description'])) {
$label .= ' — ' . $at['description'];
}
return ['id' => $at['id'], 'name' => $label];
}, $enabledAccessTypes);
$selectedAccessType = isset($formData['access_type_id'])
? (int) $formData['access_type_id']
: $defaultAccessTypeId;
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
$withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs;
$formData = $formData ?? [];
?>
<fieldset>
<legend>Métadonnées complémentaires</legend>
<?php
$name = 'license_id'; $label = 'Licence :'; $options = $licenseTypes;
$selected = $formData['license_id'] ?? ''; $placeholder = '— Inconnue —';
include APP_ROOT . '/templates/partials/form/select-field.php';
$name = 'duration_pages'; $label = 'Nombre de pages :'; $value = $oldFn('duration_pages');
$type = 'number'; $placeholder = ''; $hint = 'Ex : 84';
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php
$name = 'duration_info'; $label = 'Durée / Taille :'; $value = $oldFn('duration_info');
$placeholder = 'Ex : 84 pages'; $hint = 'Durée (minutes) ou nombre de pages.';
$name = 'duration_minutes'; $label = 'Durée (minutes) :'; $value = $oldFn('duration_minutes');
$type = 'number'; $placeholder = ''; $hint = 'Ex : 32 (pour œuvres audio/vidéo)';
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<div class="admin-form-group">
<label class="admin-checkbox-label">
<input type="checkbox" name="has_annexes" value="1"
<?= !empty($formData['has_annexes']) ? 'checked' : '' ?>>
Ce TFE comporte des annexes
</label>
</div>
<?php
$name = 'lien'; $label = 'Lien (site / ressource) :'; $value = $oldFn('lien');
$type = 'url'; $placeholder = 'https://...';
$type = 'url'; $placeholder = 'https://...'; $hint = '';
$attrs = $withAutofocusFn('lien');
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php
$name = 'access_type_id'; $label = 'Visibilité / Accès :';
$options = $accessOptions; $selected = $selectedAccessType;
$placeholder = null; $required = true; $attrs = [];
include APP_ROOT . '/templates/partials/form/select-field.php';
?>
</fieldset>
<?php
unset($oldFn, $withAutofocusFn, $defaultAccessTypeId, $showDescription, $accessOptions, $selectedAccessType);
unset($oldFn, $withAutofocusFn);