Alte Touren nach Jahren gruppieren
This commit is contained in:
parent
6b6aaf881e
commit
77df14237c
3 changed files with 213 additions and 16 deletions
|
|
@ -643,3 +643,142 @@ p {
|
|||
background-color: #1d5bc4;
|
||||
border-color: #1d5bc4;
|
||||
}
|
||||
|
||||
/* Alte Touren: Jahres-Pillen und Gruppierung */
|
||||
.tour-years {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: .5rem;
|
||||
max-width: 760px;
|
||||
margin: 1.25rem auto 2rem;
|
||||
}
|
||||
|
||||
.tour-year-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 4.35rem;
|
||||
padding: .45rem 1.15rem;
|
||||
border: 1px solid rgba(255, 255, 255, .35);
|
||||
border-radius: 999px;
|
||||
background: rgba(13, 17, 23, .55);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
text-decoration: none;
|
||||
transition: background-color .18s ease, border-color .18s ease,
|
||||
color .18s ease, transform .18s ease;
|
||||
}
|
||||
|
||||
.tour-year-pill:hover,
|
||||
.tour-year-pill:focus {
|
||||
border-color: #4ea1ff;
|
||||
background: rgba(78, 161, 255, .18);
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.tour-year-pill.is-active {
|
||||
border-color: #4ea1ff;
|
||||
background: #4ea1ff;
|
||||
color: #071a30;
|
||||
box-shadow: 0 8px 20px rgba(78, 161, 255, .35);
|
||||
}
|
||||
|
||||
.tour-years-empty {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.tour-year-group {
|
||||
max-width: 760px;
|
||||
margin: 0 auto 2rem;
|
||||
}
|
||||
|
||||
.tour-year-heading {
|
||||
margin: 0 0 .85rem;
|
||||
color: #fff;
|
||||
font-size: 1.35rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: .02em;
|
||||
}
|
||||
|
||||
.tour-list {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tour-list-item {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: .65rem 1rem;
|
||||
background: rgba(13, 17, 23, .72);
|
||||
border-color: rgba(255, 255, 255, .14);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tour-list-link {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: .35rem .6rem;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.tour-list-link:hover,
|
||||
.tour-list-link:focus {
|
||||
color: #9cc9ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.tour-list-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tour-list-meta {
|
||||
color: rgba(255, 255, 255, .72);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.tour-list-actions {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: .7rem;
|
||||
}
|
||||
|
||||
.tour-gallery-link {
|
||||
color: #9cc9ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.tour-gallery-link:hover,
|
||||
.tour-gallery-link:focus {
|
||||
color: #fff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.tour-list-actions .badge {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 575.98px) {
|
||||
.tour-year-pill {
|
||||
min-width: 3.7rem;
|
||||
padding: .4rem .9rem;
|
||||
}
|
||||
|
||||
.tour-list-item {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.tour-year-pill {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,18 +32,47 @@ class TourController
|
|||
$tours = Tour::past();
|
||||
$participantCount = [];
|
||||
$imagecountPerTour = [];
|
||||
$toursByYear = [];
|
||||
|
||||
foreach ($tours as $tour) {
|
||||
$participantCount[$tour->id] = Booking::countForTour((int) $tour->id);
|
||||
|
||||
// Jahr vor der Formatierung aus dem DB-Datum (YYYY-MM-DD) lesen.
|
||||
$year = (int) substr((string) $tour->start, 0, 4);
|
||||
if ($year < 1900) {
|
||||
$year = 0;
|
||||
}
|
||||
|
||||
$tour->start = german_date($tour->start);
|
||||
$tour->deadline = german_date($tour->deadline);
|
||||
|
||||
$files = glob(storage_path('img_storage/tour-' . $tour->id) . '/*') ?: [];
|
||||
$imagecountPerTour[$tour->id] = (int) (count($files) / 2);
|
||||
|
||||
$toursByYear[$year][] = $tour;
|
||||
}
|
||||
|
||||
krsort($toursByYear, SORT_NUMERIC);
|
||||
$years = array_keys($toursByYear);
|
||||
|
||||
// Ohne Auswahl werden alle Jahre gruppiert angezeigt. ?jahr=2025 filtert.
|
||||
$requestedYear = input('jahr');
|
||||
$selectedYear = null;
|
||||
|
||||
if (is_string($requestedYear) && ctype_digit($requestedYear)) {
|
||||
$candidate = (int) $requestedYear;
|
||||
if (isset($toursByYear[$candidate])) {
|
||||
$selectedYear = $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
$visibleYears = $selectedYear === null ? $years : [$selectedYear];
|
||||
|
||||
view('tour.index_old', [
|
||||
'tours' => $tours,
|
||||
'toursByYear' => $toursByYear,
|
||||
'years' => $years,
|
||||
'visibleYears' => $visibleYears,
|
||||
'selectedYear' => $selectedYear,
|
||||
'participantCount' => $participantCount,
|
||||
'imagecountPerTour' => $imagecountPerTour,
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
use App\Models\Tour;
|
||||
|
||||
$current = auth_check() ? user() : null;
|
||||
$selectedYear = $selectedYear ?? null;
|
||||
$years = $years ?? [];
|
||||
$toursByYear = $toursByYear ?? [];
|
||||
$visibleYears = $visibleYears ?? ($selectedYear === null ? $years : [$selectedYear]);
|
||||
?>
|
||||
|
||||
<div class="container text-center text-light mt-5">
|
||||
|
|
@ -11,21 +15,46 @@
|
|||
<span class="offset-1 col-4 float-left mb-3"><a class="btn btn-success" href="/tour" class="text-center text-light"><h3>Aktuelle Touren</h3></a></span>
|
||||
</div>
|
||||
|
||||
<div class="container text-primary" style="display:flex">
|
||||
.<ul class="list-group offset-2 col-8">
|
||||
<?php foreach ($tours as $tour): ?>
|
||||
<a href="/tour/<?= e($tour->id) ?>">
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<?= e($tour->start) ?> - <?= e($tour->name) ?> [<?= e($participantCount[$tour->id] ?? 0) ?>/<?= e($tour->max_participants) ?>]
|
||||
<a href="/tour/gallery/<?= e($tour->id) ?>">( <?= e($imagecountPerTour[$tour->id] ?? 0) ?> Bilder)</a>
|
||||
<?php if ($current && Tour::hasParticipant((int) $tour->id, (int) $current->id)): ?>
|
||||
<i class="fas fa-biking"></i>
|
||||
<?php endif; ?>
|
||||
<?php if ($years === []): ?>
|
||||
<p class="tour-years-empty">Es sind noch keine abgeschlossenen Touren vorhanden.</p>
|
||||
<?php else: ?>
|
||||
<nav class="tour-years" aria-label="Alte Touren nach Jahr">
|
||||
<a class="tour-year-pill<?= $selectedYear === null ? ' is-active' : '' ?>"
|
||||
href="/tour/index_old"<?= $selectedYear === null ? ' aria-current="page"' : '' ?>>Alle</a>
|
||||
|
||||
<span class="badge <?= $tour->is_cancelled ? 'badge-danger' : 'badge-success' ?> badge-pill"><?= $tour->is_cancelled ? 'STORNIERT' : 'FINDET STATT' ?></span>
|
||||
</li>
|
||||
</a>
|
||||
<?php foreach ($years as $year): ?>
|
||||
<?php $yearLabel = ((int) $year === 0) ? 'Ohne Datum' : (string) $year; ?>
|
||||
<a class="tour-year-pill<?= $selectedYear === $year ? ' is-active' : '' ?>"
|
||||
href="/tour/index_old?jahr=<?= e($year) ?>"<?= $selectedYear === $year ? ' aria-current="page"' : '' ?>><?= e($yearLabel) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<?php foreach ($visibleYears as $year): ?>
|
||||
<?php $yearLabel = ((int) $year === 0) ? 'Ohne Datum' : (string) $year; ?>
|
||||
<section class="tour-year-group" aria-labelledby="tour-year-<?= e($year) ?>">
|
||||
<h2 class="tour-year-heading" id="tour-year-<?= e($year) ?>"><?= e($yearLabel) ?></h2>
|
||||
|
||||
<ul class="list-group tour-list">
|
||||
<?php foreach ($toursByYear[$year] ?? [] as $tour): ?>
|
||||
<li class="list-group-item tour-list-item">
|
||||
<a class="tour-list-link" href="/tour/<?= e($tour->id) ?>">
|
||||
<span class="tour-list-title"><?= e($tour->start) ?> - <?= e($tour->name) ?></span>
|
||||
<span class="tour-list-meta">[<?= e($participantCount[$tour->id] ?? 0) ?>/<?= e($tour->max_participants) ?>]</span>
|
||||
</a>
|
||||
|
||||
<span class="tour-list-actions">
|
||||
<a class="tour-gallery-link" href="/tour/gallery/<?= e($tour->id) ?>">( <?= e($imagecountPerTour[$tour->id] ?? 0) ?> Bilder)</a>
|
||||
|
||||
<?php if ($current && Tour::hasParticipant((int) $tour->id, (int) $current->id)): ?>
|
||||
<i class="fas fa-biking" title="Du hast teilgenommen" aria-label="Du hast teilgenommen"></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="badge <?= $tour->is_cancelled ? 'badge-danger' : 'badge-success' ?> badge-pill"><?= $tour->is_cancelled ? 'STORNIERT' : 'FINDET STATT' ?></span>
|
||||
</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue