mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: student name popover preview on /repertoire via htmx
This commit is contained in:
@@ -17,17 +17,19 @@ $activeSets = [
|
||||
];
|
||||
|
||||
// Build the student map from matched students only
|
||||
$studentMap = []; // name => id
|
||||
// name => [id, id, ...] (a student may have multiple theses)
|
||||
$studentWorks = []; // name => [thesis ids]
|
||||
foreach ($repData['students'] as $s) {
|
||||
if (empty($s['authors'])) continue;
|
||||
foreach (explode(',', $s['authors']) as $name) {
|
||||
$name = trim($name);
|
||||
if ($name !== '' && !isset($studentMap[$name])) {
|
||||
$studentMap[$name] = (int)$s['id'];
|
||||
}
|
||||
if ($name === '') continue;
|
||||
$studentWorks[$name][] = (int)$s['id'];
|
||||
}
|
||||
}
|
||||
ksort($studentMap);
|
||||
ksort($studentWorks);
|
||||
// Legacy alias for single-id use
|
||||
$studentMap = array_map(fn($ids) => $ids[0], $studentWorks);
|
||||
|
||||
/**
|
||||
* Build the toggle URL for a filter button.
|
||||
@@ -170,12 +172,23 @@ $hx = 'hx-target="#repertoire-index" hx-swap="outerHTML" hx-push-url="true" hx-i
|
||||
<section class="repertoire-col" data-col="students">
|
||||
<h2>Étudiantes</h2>
|
||||
<ul>
|
||||
<?php if (empty($studentMap)): ?>
|
||||
<?php if (empty($studentWorks)): ?>
|
||||
<li class="rep-empty">—</li>
|
||||
<?php else: ?>
|
||||
<?php foreach ($studentMap as $name => $id): ?>
|
||||
<li>
|
||||
<a href="/tfe?id=<?= (int)$id ?>" class="rep-entry rep-entry--link">
|
||||
<?php foreach ($studentWorks as $name => $ids): ?>
|
||||
<?php
|
||||
$firstId = $ids[0];
|
||||
$previewUrl = '/repertoire/student-preview?name=' . urlencode($name);
|
||||
$targetUrl = count($ids) === 1 ? '/tfe?id=' . $firstId : '#';
|
||||
?>
|
||||
<li class="student-entry">
|
||||
<a href="<?= htmlspecialchars($targetUrl) ?>"
|
||||
class="rep-entry rep-entry--link"
|
||||
hx-get="<?= htmlspecialchars($previewUrl) ?>"
|
||||
hx-target="#student-popover"
|
||||
hx-trigger="mouseenter"
|
||||
hx-swap="innerHTML"
|
||||
data-student-name="<?= htmlspecialchars($name) ?>">
|
||||
<?= htmlspecialchars($name) ?>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
28
app/templates/partials/student-preview.php
Normal file
28
app/templates/partials/student-preview.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Partial: student popover preview.
|
||||
*
|
||||
* Expected variables:
|
||||
* $theses array rows of [id => int, title => string]
|
||||
* $name string student name
|
||||
*/
|
||||
?>
|
||||
<?php if (count($theses) === 1): ?>
|
||||
<iframe
|
||||
src="/tfe?id=<?= (int)$theses[0]['id'] ?>"
|
||||
class="student-preview__iframe"
|
||||
loading="lazy"
|
||||
title="Aperçu — <?= htmlspecialchars($name) ?>"
|
||||
></iframe>
|
||||
<?php else: ?>
|
||||
<p class="student-preview__name"><?= htmlspecialchars($name) ?></p>
|
||||
<ul class="student-preview__list">
|
||||
<?php foreach ($theses as $t): ?>
|
||||
<li>
|
||||
<a href="/tfe?id=<?= (int)$t['id'] ?>" class="student-preview__link">
|
||||
<?= htmlspecialchars($t['title']) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user