mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add language-search component for Autre Langue input + active search in lists
Mirrors the mots-clé tag-search system: dropdown suggestions from existing languages via HTMX, pill display with bin-icon remove buttons, 'Créer' option for new languages. Replaces the plain text input. - New partial: templates/partials/form/language-search.php - New fragment: public/partage/language-search-fragment.php - Admin wrapper: public/admin/language-search-fragment.php - Updated language-autre-fragment to return just the required asterisk indicator - Updated both controllers to handle language_autre as array (pill-based) with backward-compatible string path - Updated edit form to compute selectedOtherLanguages from DB - Registered new route in partage/index.php - Fix CSV importer: split comma-separated language column into individual entries - Add htmx active search to admin index, title line-clamp, predefined languages only in checkboxes - Admin index: filter form now uses htmx triggers (input delay:300ms on search, change on selects) to actively search without page reload - Sort links include hx-push-url for back-button support - Added loading indicator bar (.admin-search-indicator) - Title column: line-clamp at 2 lines with overflow hidden, native title attr tooltip for full text - Language checkboxes now show only 3 predefined languages (Français, Anglais, Néerlandais); all others go via the Autre langue search component - Added Database::getPredefinedLanguages() and excluded predefined from language-search-fragment suggestions - Included hidden sort/dir inputs in table-wrap so sort state preserved across filter changes - Fix language-search: block 'Créer' for predefined languages in dropdown The 'Créer' option in the language-search dropdown now also checks against the predefined set (français, anglais, néerlandais) to avoid offering creation of languages that already exist as checkboxes.
This commit is contained in:
@@ -186,29 +186,45 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
||||
$checked = $formData["languages"] ?? [];
|
||||
$required = !$adminMode;
|
||||
$hxPost = $mode === 'partage' ? "/partage/language-autre-fragment" : "/admin/language-autre-fragment.php";
|
||||
$hxTarget = "#language-autre-row";
|
||||
$hxTarget = "#language-autre-required";
|
||||
$hxSwap = "outerHTML";
|
||||
include APP_ROOT . "/templates/partials/form/checkbox-list.php";
|
||||
unset($hxSwap);
|
||||
?>
|
||||
<?php
|
||||
$_langAutreRequired = empty($formData["languages"]);
|
||||
$_langAutreValue = $oldFn("language_autre");
|
||||
// Build selectedLanguages array from form data or current other languages
|
||||
$_selectedOtherLangs = [];
|
||||
if (!empty($formData['language_autre']) && is_array($formData['language_autre'])) {
|
||||
foreach ($formData['language_autre'] as $_l) {
|
||||
if (is_string($_l) && trim($_l) !== '') {
|
||||
$_selectedOtherLangs[] = ['name' => trim($_l)];
|
||||
}
|
||||
}
|
||||
} elseif (!empty($selectedOtherLanguages) && is_array($selectedOtherLanguages)) {
|
||||
$_selectedOtherLangs = array_map(fn($n) => ['name' => $n], $selectedOtherLanguages);
|
||||
} else {
|
||||
$_langRaw = $formData["language_autre"] ?? '';
|
||||
if (is_string($_langRaw) && $_langRaw !== '') {
|
||||
foreach (array_map('trim', explode(',', $_langRaw)) as $_l) {
|
||||
if ($_l !== '') {
|
||||
$_selectedOtherLangs[] = ['name' => $_l];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$name = "language_autre";
|
||||
$label = "Autre(s) langue(s) :";
|
||||
$placeholder = "Rechercher une langue…";
|
||||
$hint = "Si votre TFE contient une langue absente de la liste, précisez-la ici.";
|
||||
$selectedLanguages = $_selectedOtherLangs;
|
||||
$required = $_langAutreRequired && !$adminMode;
|
||||
$hxPost = ($mode === 'partage') ? "/partage/language-search-fragment" : "/admin/language-search-fragment.php";
|
||||
include APP_ROOT . "/templates/partials/form/language-search.php";
|
||||
unset($_langAutreRequired, $_selectedOtherLangs, $_langRaw, $_l, $name, $label, $placeholder, $hint, $selectedLanguages, $required, $hxPost);
|
||||
?>
|
||||
<div id="language-autre-row">
|
||||
<div>
|
||||
<label for="language_autre">Autre(s) langue(s) :<?= $_langAutreRequired ? ' <span class="asterisk">*</span>' : '' ?></label>
|
||||
<div>
|
||||
<input type="text"
|
||||
id="language_autre"
|
||||
name="language_autre"
|
||||
value="<?= $_langAutreValue ?>"
|
||||
<?= (!$adminMode && $_langAutreRequired) ? 'required' : '' ?>>
|
||||
<small>Si votre TFE contient une langue absente de la liste, précisez-la ici.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php unset($_langAutreRequired, $_langAutreValue); ?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Mots-clés ═══════════════════ -->
|
||||
|
||||
Reference in New Issue
Block a user