tfe: redirect internal metadata links from /repertoire to /search

redirect internal metadata links from /repertoire to /search, add query param for search bar prefill, fix filter visibility on desktop

 redirect metadata links from /repertoire to /search, prefill search bar, fix filter visibility

 link metadata to /search, preserve keyword filter in form, show active keyword chip
This commit is contained in:
Pontoporeia
2026-07-10 14:16:36 +02:00
parent f5a7d70fbc
commit f427352a71
4 changed files with 63 additions and 8 deletions
+1
View File
@@ -50,3 +50,4 @@
- [x] Fix: locked_year cleared on edit — edit dialog didn't populate the field, so any edit cleared the locked academic year - [x] Fix: locked_year cleared on edit — edit dialog didn't populate the field, so any edit cleared the locked academic year
- [x] Fix repertoire Années column: sort reverse chronological (newest first) instead of ascending alpha - [x] Fix repertoire Années column: sort reverse chronological (newest first) instead of ascending alpha
- [x] TFE website embed: wrap iframe + button in overlay-style div with "Site web" pill badge on left corner, clearer link text - [x] TFE website embed: wrap iframe + button in overlay-style div with "Site web" pill badge on left corner, clearer link text
- [x] Redirect internal metadata links on TFE page from /repertoire to /search (orientation, AP, finalité, year, keywords); add query= for search bar prefill; fix filter <details> visibility on desktop; add keyword to filterKeys badge; add hidden keyword input + visible chip to filter form so keyword filter survives form submission
+32
View File
@@ -537,6 +537,38 @@
cursor: default; cursor: default;
} }
/* Active keyword chip in filter bar */
.search-active-keyword {
display: inline-flex;
align-items: center;
gap: var(--space-3xs);
background: var(--surface-secondary);
border: 1px solid var(--border-secondary);
border-radius: var(--radius-sm);
padding: var(--space-3xs) var(--space-xs);
font-size: var(--step--2);
color: var(--text-secondary);
white-space: nowrap;
}
.search-active-keyword strong {
color: var(--text-primary);
font-weight: 500;
}
.search-keyword-remove {
color: var(--text-secondary);
text-decoration: none;
font-size: 1.1em;
line-height: 1;
padding: 0 var(--space-4xs);
margin-left: var(--space-4xs);
}
.search-keyword-remove:hover {
color: var(--accent-primary);
}
.search-filter-select { .search-filter-select {
font-size: var(--step--1); font-size: var(--step--1);
padding: var(--space-3xs) var(--space-2xs); padding: var(--space-3xs) var(--space-2xs);
+24 -2
View File
@@ -4,14 +4,14 @@
<?php <?php
// Count active filters (excluding 'query' and 'page') // Count active filters (excluding 'query' and 'page')
$filterKeys = ['year', 'ap_program', 'orientation', 'finality', 'format']; $filterKeys = ['year', 'ap_program', 'orientation', 'finality', 'format', 'keyword'];
$activeFilterCount = 0; $activeFilterCount = 0;
foreach ($filterKeys as $k) { foreach ($filterKeys as $k) {
if (!empty($_GET[$k])) $activeFilterCount++; if (!empty($_GET[$k])) $activeFilterCount++;
} }
?> ?>
<!-- Filter controls --> <!-- Filter controls -->
<details class="search-filters-toggle"> <details class="search-filters-toggle" open>
<summary class="search-filters-summary"> <summary class="search-filters-summary">
Filtres Filtres
<?php if ($activeFilterCount > 0): ?> <?php if ($activeFilterCount > 0): ?>
@@ -20,6 +20,12 @@ foreach ($filterKeys as $k) {
</summary> </summary>
<form class="search-controls" method="GET" action="/search"> <form class="search-controls" method="GET" action="/search">
<input type="hidden" name="query" value="<?= htmlspecialchars($_GET['query'] ?? '') ?>"> <input type="hidden" name="query" value="<?= htmlspecialchars($_GET['query'] ?? '') ?>">
<?php if (!empty($_GET['keyword'])): ?>
<input type="hidden" name="keyword" value="<?= htmlspecialchars($_GET['keyword']) ?>">
<span class="search-active-keyword">Mot-clé&nbsp;: <strong><?= htmlspecialchars($_GET['keyword']) ?></strong>
<a href="/search?query=<?= urlencode($_GET['query'] ?? '') ?>" class="search-keyword-remove" aria-label="Retirer le filtre mot-clé">×</a>
</span>
<?php endif; ?>
<label class="search-filter-label" for="filter-year">Année <label class="search-filter-label" for="filter-year">Année
<select class="search-filter-select" name="year" id="filter-year"> <select class="search-filter-select" name="year" id="filter-year">
@@ -88,3 +94,19 @@ foreach ($filterKeys as $k) {
<main class="search-main" id="main-content"> <main class="search-main" id="main-content">
<?php include APP_ROOT . '/templates/partials/search-results.php'; ?> <?php include APP_ROOT . '/templates/partials/search-results.php'; ?>
</main> </main>
<script>
// Close filter <details> on mobile by default when no filters active
(function() {
if (window.innerWidth > 768) return;
var params = new URLSearchParams(window.location.search);
var hasActive = false;
params.forEach(function(v, k) {
if (k === 'page' || k === 'query') return;
if (v !== '') hasActive = true;
});
if (hasActive) return;
var toggle = document.querySelector('.search-filters-toggle');
if (toggle) toggle.removeAttribute('open');
})();
</script>
+6 -6
View File
@@ -18,28 +18,28 @@
<?php if (!empty($data["orientation"])): ?> <?php if (!empty($data["orientation"])): ?>
<p class="tfe-meta-item"> <p class="tfe-meta-item">
<span class="tfe-meta-label">Orientation :</span> <span class="tfe-meta-label">Orientation :</span>
<a href="/repertoire?or[]=<?= urlencode($data["orientation"]) ?>"><?= htmlspecialchars($data["orientation"]) ?></a> <a href="/search?orientation=<?= urlencode($data["orientation"]) ?>&query=<?= urlencode($data["orientation"]) ?>"><?= htmlspecialchars($data["orientation"]) ?></a>
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($data["ap_program"])): ?> <?php if (!empty($data["ap_program"])): ?>
<p class="tfe-meta-item"> <p class="tfe-meta-item">
<span class="tfe-meta-label">Atelier pluridisciplinaire :</span> <span class="tfe-meta-label">Atelier pluridisciplinaire :</span>
<a href="/repertoire?ap[]=<?= urlencode($data["ap_program"]) ?>"><?= htmlspecialchars($data["ap_program"]) ?></a> <a href="/search?ap_program=<?= urlencode($data["ap_program"]) ?>&query=<?= urlencode($data["ap_program"]) ?>"><?= htmlspecialchars($data["ap_program"]) ?></a>
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($data["finality_type"])): ?> <?php if (!empty($data["finality_type"])): ?>
<p class="tfe-meta-item"> <p class="tfe-meta-item">
<span class="tfe-meta-label">Finalité :</span> <span class="tfe-meta-label">Finalité :</span>
<a href="/repertoire?fi[]=<?= urlencode($data["finality_type"]) ?>"><?= htmlspecialchars($data["finality_type"]) ?></a> <a href="/search?finality=<?= urlencode($data["finality_type"]) ?>&query=<?= urlencode($data["finality_type"]) ?>"><?= htmlspecialchars($data["finality_type"]) ?></a>
</p> </p>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($data["year"])): ?> <?php if (!empty($data["year"])): ?>
<p class="tfe-meta-item"> <p class="tfe-meta-item">
<span class="tfe-meta-label">Date :</span> <span class="tfe-meta-label">Date :</span>
<a href="/repertoire?fy[]=<?= urlencode($data["year"]) ?>"><?= htmlspecialchars($data["year"]) ?></a> <a href="/search?year=<?= urlencode($data["year"]) ?>&query=<?= urlencode($data["year"]) ?>"><?= htmlspecialchars($data["year"]) ?></a>
</p> </p>
<?php endif; ?> <?php endif; ?>
@@ -83,7 +83,7 @@
<?php <?php
$fmts = array_map("trim", explode(",", $data["formats"])); $fmts = array_map("trim", explode(",", $data["formats"]));
$fmtLinks = array_map( $fmtLinks = array_map(
fn($f) => '<a href="/search?query=' . urlencode($f) . '">' . htmlspecialchars(mb_strtolower($f)) . '</a>', fn($f) => '<a href="/search?format=' . urlencode($f) . '&query=' . urlencode($f) . '">' . htmlspecialchars(mb_strtolower($f)) . '</a>',
$fmts, $fmts,
); );
echo implode(", ", $fmtLinks); echo implode(", ", $fmtLinks);
@@ -97,7 +97,7 @@
<?php <?php
$kws = array_map("trim", explode(",", $data["keywords"])); $kws = array_map("trim", explode(",", $data["keywords"]));
$kwLinks = array_map( $kwLinks = array_map(
fn($k) => '<a href="/repertoire?kw[]=' . urlencode($k) . '">' . htmlspecialchars(mb_strtolower($k)) . '</a>', fn($k) => '<a href="/search?keyword=' . urlencode($k) . '&query=' . urlencode($k) . '">' . htmlspecialchars(mb_strtolower($k)) . '</a>',
$kws, $kws,
); );
echo implode(", ", $kwLinks); echo implode(", ", $kwLinks);