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:
@@ -194,12 +194,6 @@ class AdminLogger
|
||||
]);
|
||||
}
|
||||
|
||||
/** Parametres: delete all TFEs */
|
||||
public function logDeleteAllTheses(int $count): void
|
||||
{
|
||||
$this->write('system', 'delete_all_theses', 'success', ['count' => $count]);
|
||||
}
|
||||
|
||||
/** Parametres: formulaire section toggles */
|
||||
public function logFormSettingsUpdate(array $newValues): void
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ class ThesisCreateController
|
||||
'orientations' => $this->db->getAllOrientations(),
|
||||
'apPrograms' => $this->db->getAllAPPrograms(),
|
||||
'finalityTypes' => $this->db->getAllFinalityTypes(),
|
||||
'languages' => $this->db->getAllLanguages(),
|
||||
'languages' => $this->db->getPredefinedLanguages(),
|
||||
'formatTypes' => $this->db->getAllFormatTypes(),
|
||||
'licenseTypes' => $this->db->getAllLicenseTypes(),
|
||||
'enabledAccessTypes' => $this->db->getEnabledFormAccessTypes(),
|
||||
@@ -467,8 +467,16 @@ class ThesisCreateController
|
||||
$languageIds = isset($post['languages']) && is_array($post['languages'])
|
||||
? array_map('intval', $post['languages'])
|
||||
: [];
|
||||
$autreRaw = trim($post['language_autre'] ?? '');
|
||||
if ($autreRaw !== '') {
|
||||
// language_autre: pill-based component sends an array; also handle legacy comma-separated string
|
||||
$autreRaw = $post['language_autre'] ?? '';
|
||||
if (is_array($autreRaw)) {
|
||||
foreach ($autreRaw as $langName) {
|
||||
$langName = trim($langName);
|
||||
if ($langName !== '') {
|
||||
$languageIds[] = $this->db->getOrCreateLanguage($langName);
|
||||
}
|
||||
}
|
||||
} elseif (is_string($autreRaw) && trim($autreRaw) !== '') {
|
||||
foreach (array_map('trim', explode(',', $autreRaw)) as $langName) {
|
||||
if ($langName !== '') {
|
||||
$languageIds[] = $this->db->getOrCreateLanguage($langName);
|
||||
|
||||
@@ -95,7 +95,7 @@ class ThesisEditController
|
||||
$orientations = $this->db->getAllOrientations();
|
||||
$apPrograms = $this->db->getAllAPPrograms();
|
||||
$finalityTypes = $this->db->getAllFinalityTypes();
|
||||
$languages = $this->db->getAllLanguages();
|
||||
$languages = $this->db->getPredefinedLanguages();
|
||||
$formatTypes = $this->db->getAllFormatTypes();
|
||||
$licenseTypes = $this->db->getAllLicenseTypes();
|
||||
$enabledAccessTypes = $this->db->getEnabledFormAccessTypes();
|
||||
@@ -247,8 +247,16 @@ class ThesisEditController
|
||||
$langIds = isset($post['languages']) && is_array($post['languages'])
|
||||
? $post['languages']
|
||||
: [];
|
||||
$autreRaw = trim($post['language_autre'] ?? '');
|
||||
if ($autreRaw !== '') {
|
||||
// language_autre: pill-based component sends an array; also handle legacy comma-separated string
|
||||
$autreRaw = $post['language_autre'] ?? '';
|
||||
if (is_array($autreRaw)) {
|
||||
foreach ($autreRaw as $langName) {
|
||||
$langName = trim($langName);
|
||||
if ($langName !== '') {
|
||||
$langIds[] = (string)$this->db->getOrCreateLanguage($langName);
|
||||
}
|
||||
}
|
||||
} elseif (is_string($autreRaw) && trim($autreRaw) !== '') {
|
||||
foreach (array_map('trim', explode(',', $autreRaw)) as $langName) {
|
||||
if ($langName !== '') {
|
||||
$langIds[] = (string)$this->db->getOrCreateLanguage($langName);
|
||||
|
||||
@@ -752,6 +752,21 @@ class Database
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return only the predefined / hardcoded languages used as checkboxes
|
||||
* in the form. All other languages go into the "Autre langue" input.
|
||||
*/
|
||||
public function getPredefinedLanguages(): array
|
||||
{
|
||||
$stmt = $this->pdo->query(
|
||||
"SELECT id, UPPER(SUBSTR(name,1,1)) || SUBSTR(name,2) as name, created_at
|
||||
FROM languages
|
||||
WHERE LOWER(name) IN ('français', 'anglais', 'néerlandais', 'francais', 'neerlandais')
|
||||
ORDER BY name"
|
||||
);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// ADMIN LIST METHOD
|
||||
// ========================================================================
|
||||
@@ -1940,17 +1955,6 @@ class Database
|
||||
/**
|
||||
* Delete every thesis in the database.
|
||||
*/
|
||||
public function deleteAllTheses(): int
|
||||
{
|
||||
$ids = $this->pdo->query('SELECT id FROM theses')->fetchAll(\PDO::FETCH_COLUMN);
|
||||
if (empty($ids)) {
|
||||
return 0;
|
||||
}
|
||||
$count = count($ids);
|
||||
$this->bulkDeleteTheses($ids);
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a thesis file record.
|
||||
* sort_order defaults to (max existing sort_order + 1) for the thesis.
|
||||
|
||||
Reference in New Issue
Block a user