Lumishop: categories in their own panel on the left with item counts, modern search bar
- Category list below each other with counts, active category highlighted in gold, sticky while scrolling; on phones a swipeable row - Search field in the same round style as elsewhere, with a "x of y" count Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
8d7b729744
commit
3c9574c430
3 changed files with 116 additions and 19 deletions
|
|
@ -5686,3 +5686,60 @@ html.has-scroll-progress::-webkit-scrollbar { display: none; }
|
||||||
@media print {
|
@media print {
|
||||||
.scroll-progress { display: none; }
|
.scroll-progress { display: none; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---- Lumishop: Kategorien links, Suche und Gegenstaende rechts ---- */
|
||||||
|
.shop-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
|
||||||
|
.shop-layout-single { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
.shop-layout > .panel { margin-bottom: 0; }
|
||||||
|
.shop-layout + .panel { margin-top: 1.25rem; }
|
||||||
|
|
||||||
|
.shop-categories { position: sticky; top: 1rem; padding: 1rem 0.75rem; }
|
||||||
|
.shop-categories h2 { display: flex; align-items: center; gap: 0.45rem; margin: 0 0.5rem 0.75rem; font-size: 1.05rem; }
|
||||||
|
.shop-categories h2 .icon { width: 18px; height: 18px; color: var(--gold); }
|
||||||
|
.shop-category-list { display: flex; flex-direction: column; gap: 0.2rem; }
|
||||||
|
.shop-category {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.6rem;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.55rem 0.7rem;
|
||||||
|
border: 0;
|
||||||
|
border-left: 3px solid transparent;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text);
|
||||||
|
font-size: 0.93rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.shop-category:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
|
||||||
|
.shop-category.active { background: rgba(201, 162, 39, 0.14); border-left-color: var(--gold); color: var(--gold); font-weight: 600; }
|
||||||
|
.shop-category > span:first-child { min-width: 0; overflow-wrap: anywhere; }
|
||||||
|
.shop-category-count {
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-width: 1.8rem;
|
||||||
|
padding: 0.05rem 0.45rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.shop-category.active .shop-category-count { background: var(--gold); color: #1a1a1a; }
|
||||||
|
|
||||||
|
.shop-searchbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1.1rem; }
|
||||||
|
.shop-searchbar .search-field { flex: 1 1 260px; }
|
||||||
|
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.shop-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
|
||||||
|
.shop-categories { position: static; padding: 0.75rem; }
|
||||||
|
.shop-categories h2 { display: none; }
|
||||||
|
/* Auf dem Handy: Kategorien als waagerecht scrollbare Leiste */
|
||||||
|
.shop-category-list { flex-direction: row; overflow-x: auto; gap: 0.4rem; scrollbar-width: none; }
|
||||||
|
.shop-category-list::-webkit-scrollbar { display: none; }
|
||||||
|
.shop-category { width: auto; flex-shrink: 0; border-left: 0; border: 1px solid var(--border); border-radius: 999px; padding: 0.4rem 0.8rem; }
|
||||||
|
.shop-category.active { border-color: var(--gold); }
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,11 @@
|
||||||
if (search && grid) {
|
if (search && grid) {
|
||||||
var category = document.getElementById('shop-category');
|
var category = document.getElementById('shop-category');
|
||||||
var noMatch = document.getElementById('shop-no-match');
|
var noMatch = document.getElementById('shop-no-match');
|
||||||
|
var count = document.getElementById('shop-count');
|
||||||
|
var total = grid.querySelectorAll('.shop-card').length;
|
||||||
|
var cat = '';
|
||||||
var filter = function () {
|
var filter = function () {
|
||||||
var term = search.value.trim().toLowerCase();
|
var term = search.value.trim().toLowerCase();
|
||||||
var cat = category ? category.value : '';
|
|
||||||
var visible = 0;
|
var visible = 0;
|
||||||
grid.querySelectorAll('.shop-card').forEach(function (card) {
|
grid.querySelectorAll('.shop-card').forEach(function (card) {
|
||||||
var show = (term === '' || card.dataset.name.indexOf(term) !== -1)
|
var show = (term === '' || card.dataset.name.indexOf(term) !== -1)
|
||||||
|
|
@ -78,9 +80,27 @@
|
||||||
if (show) visible++;
|
if (show) visible++;
|
||||||
});
|
});
|
||||||
if (noMatch) noMatch.hidden = visible > 0;
|
if (noMatch) noMatch.hidden = visible > 0;
|
||||||
|
if (count) {
|
||||||
|
count.textContent = visible === total
|
||||||
|
? total + (total === 1 ? ' Gegenstand' : ' Gegenstände')
|
||||||
|
: visible + ' von ' + total;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
search.addEventListener('input', filter);
|
search.addEventListener('input', filter);
|
||||||
if (category) category.addEventListener('change', filter);
|
// Kategorien im Kasten links: Klick waehlt aus (und markiert den Eintrag)
|
||||||
|
if (category) {
|
||||||
|
category.addEventListener('click', function (event) {
|
||||||
|
var button = event.target.closest('.shop-category');
|
||||||
|
if (!button) return;
|
||||||
|
cat = button.dataset.value;
|
||||||
|
category.querySelectorAll('.shop-category').forEach(function (b) {
|
||||||
|
var on = b === button;
|
||||||
|
b.classList.toggle('active', on);
|
||||||
|
b.setAttribute('aria-pressed', String(on));
|
||||||
|
});
|
||||||
|
filter();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Antraege: Grund abfragen (Ablehnen / Stornieren) ----
|
// ---- Antraege: Grund abfragen (Ablehnen / Stornieren) ----
|
||||||
|
|
|
||||||
46
shop.php
46
shop.php
|
|
@ -11,13 +11,18 @@ $reservedPoints = shop_reserved_points($userId);
|
||||||
$spendable = max(0, $balance - $reservedPoints);
|
$spendable = max(0, $balance - $reservedPoints);
|
||||||
|
|
||||||
$items = shop_items(true);
|
$items = shop_items(true);
|
||||||
|
// Kategorien fuer den Kasten links: Name und Anzahl der Gegenstaende (0 = ohne Kategorie)
|
||||||
$categories = [];
|
$categories = [];
|
||||||
|
$categoryCounts = [];
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if ($item['category_id'] !== null) {
|
$categoryId = (int) ($item['category_id'] ?? 0);
|
||||||
$categories[(int) $item['category_id']] = (string) $item['category_name'];
|
if ($categoryId > 0) {
|
||||||
|
$categories[$categoryId] = (string) $item['category_name'];
|
||||||
}
|
}
|
||||||
|
$categoryCounts[$categoryId] = ($categoryCounts[$categoryId] ?? 0) + 1;
|
||||||
}
|
}
|
||||||
$hasUncategorized = (bool) array_filter($items, static fn (array $i): bool => $i['category_id'] === null);
|
$hasUncategorized = !empty($categoryCounts[0]);
|
||||||
|
$showCategoryList = count($categories) + ($hasUncategorized ? 1 : 0) > 1;
|
||||||
|
|
||||||
// Eigene Antraege
|
// Eigene Antraege
|
||||||
$perPage = 10;
|
$perPage = 10;
|
||||||
|
|
@ -57,21 +62,35 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel">
|
<div class="shop-layout<?= $showCategoryList ? '' : ' shop-layout-single' ?>">
|
||||||
<div class="warehouse-filters">
|
<?php if ($showCategoryList): ?>
|
||||||
<input type="search" id="shop-search" placeholder="Gegenstand suchen …" autocomplete="off">
|
<aside class="panel shop-categories" aria-label="Kategorien">
|
||||||
<?php if (count($categories) + ($hasUncategorized ? 1 : 0) > 1): ?>
|
<h2><?= icon('list') ?> Kategorien</h2>
|
||||||
<select id="shop-category">
|
<div class="shop-category-list" id="shop-category" role="group">
|
||||||
<option value="">Alle Kategorien</option>
|
<button type="button" class="shop-category active" data-value="" aria-pressed="true">
|
||||||
|
<span>Alle</span><span class="shop-category-count"><?= count($items) ?></span>
|
||||||
|
</button>
|
||||||
<?php foreach ($categories as $id => $name): ?>
|
<?php foreach ($categories as $id => $name): ?>
|
||||||
<option value="<?= (int) $id ?>"><?= e($name) ?></option>
|
<button type="button" class="shop-category" data-value="<?= (int) $id ?>" aria-pressed="false">
|
||||||
|
<span><?= e($name) ?></span><span class="shop-category-count"><?= (int) ($categoryCounts[$id] ?? 0) ?></span>
|
||||||
|
</button>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php if ($hasUncategorized): ?>
|
<?php if ($hasUncategorized): ?>
|
||||||
<option value="0">Ohne Kategorie</option>
|
<button type="button" class="shop-category" data-value="0" aria-pressed="false">
|
||||||
<?php endif; ?>
|
<span>Ohne Kategorie</span><span class="shop-category-count"><?= (int) $categoryCounts[0] ?></span>
|
||||||
</select>
|
</button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
</aside>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="panel shop-main">
|
||||||
|
<div class="shop-searchbar">
|
||||||
|
<label class="search-field">
|
||||||
|
<?= icon('search') ?>
|
||||||
|
<input type="search" id="shop-search" placeholder="Gegenstand suchen …" autocomplete="off" aria-label="Lumishop durchsuchen">
|
||||||
|
</label>
|
||||||
|
<span class="list-search-count text-muted" id="shop-count"><?= count($items) ?> <?= count($items) === 1 ? 'Gegenstand' : 'Gegenstände' ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if (empty($items)): ?>
|
<?php if (empty($items)): ?>
|
||||||
<p class="text-muted">Im Lumishop gibt es gerade nichts.<?= $canManage ? ' Unter „Shop verwalten“ legst du Gegenstände an oder übernimmst sie aus dem Lagerhaus.' : '' ?></p>
|
<p class="text-muted">Im Lumishop gibt es gerade nichts.<?= $canManage ? ' Unter „Shop verwalten“ legst du Gegenstände an oder übernimmst sie aus dem Lagerhaus.' : '' ?></p>
|
||||||
|
|
@ -110,6 +129,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<p class="text-muted warehouse-no-match" id="shop-no-match" hidden>Kein Gegenstand passt zur Suche.</p>
|
<p class="text-muted warehouse-no-match" id="shop-no-match" hidden>Kein Gegenstand passt zur Suche.</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="panel" id="antraege">
|
<div class="panel" id="antraege">
|
||||||
<h2>Meine Anträge</h2>
|
<h2>Meine Anträge</h2>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue