mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 07:11:18 +02:00
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:
@@ -537,6 +537,38 @@
|
||||
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 {
|
||||
font-size: var(--step--1);
|
||||
padding: var(--space-3xs) var(--space-2xs);
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
<?php
|
||||
// Count active filters (excluding 'query' and 'page')
|
||||
$filterKeys = ['year', 'ap_program', 'orientation', 'finality', 'format'];
|
||||
$filterKeys = ['year', 'ap_program', 'orientation', 'finality', 'format', 'keyword'];
|
||||
$activeFilterCount = 0;
|
||||
foreach ($filterKeys as $k) {
|
||||
if (!empty($_GET[$k])) $activeFilterCount++;
|
||||
}
|
||||
?>
|
||||
<!-- Filter controls -->
|
||||
<details class="search-filters-toggle">
|
||||
<details class="search-filters-toggle" open>
|
||||
<summary class="search-filters-summary">
|
||||
Filtres
|
||||
<?php if ($activeFilterCount > 0): ?>
|
||||
@@ -20,6 +20,12 @@ foreach ($filterKeys as $k) {
|
||||
</summary>
|
||||
<form class="search-controls" method="GET" action="/search">
|
||||
<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é : <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
|
||||
<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">
|
||||
<?php include APP_ROOT . '/templates/partials/search-results.php'; ?>
|
||||
</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>
|
||||
|
||||
@@ -18,28 +18,28 @@
|
||||
<?php if (!empty($data["orientation"])): ?>
|
||||
<p class="tfe-meta-item">
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($data["ap_program"])): ?>
|
||||
<p class="tfe-meta-item">
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($data["finality_type"])): ?>
|
||||
<p class="tfe-meta-item">
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($data["year"])): ?>
|
||||
<p class="tfe-meta-item">
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<?php
|
||||
$fmts = array_map("trim", explode(",", $data["formats"]));
|
||||
$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,
|
||||
);
|
||||
echo implode(", ", $fmtLinks);
|
||||
@@ -97,7 +97,7 @@
|
||||
<?php
|
||||
$kws = array_map("trim", explode(",", $data["keywords"]));
|
||||
$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,
|
||||
);
|
||||
echo implode(", ", $kwLinks);
|
||||
|
||||
Reference in New Issue
Block a user