updatet sidebar styling and texts, included statistics in category-filter

This commit was merged in pull request #15.
This commit is contained in:
2026-05-13 14:21:05 +02:00
parent cc8bdd4ea1
commit ac40c7d949
3 changed files with 60 additions and 83 deletions

View File

@@ -346,7 +346,7 @@ function loadContributions() {
layerControl.addOverlay(contributionsLayer, '<i class="fa-solid fa-map-pin" style="color:#C00000;"></i> Beiträge');
// Update Sidebar List and Statistics
updateContributionsList();
updateStatistics();
buildCategoryFilter();
});
}
@@ -766,7 +766,7 @@ function updateContributionsList() {
// Builds HTML
if (filtered.length === 0) {
container.innerHTML = '<p style="text-align:center;color:#999;padding:20px;">Keine Beiträge gefunden.</p>';
container.innerHTML = '<p class="empty-state">Keine Beiträge gefunden.</p>';
return;
}
@@ -830,22 +830,33 @@ document.getElementById('list-search-input').addEventListener('input', function
// Block 12: Sidebar Category Filter and Statistics
// =====================================================================
// Builds Category Filter Checkboxes
// Builds Category Filter Checkboxes with Counts
function buildCategoryFilter() {
const container = document.getElementById('category-filter');
const counts = {};
contributionsData.forEach(function (f) {
const cat = f.properties.category;
counts[cat] = (counts[cat] || 0) + 1;
});
const total = contributionsData.length;
let html = '';
for (const key in CATEGORIES) {
const cat = CATEGORIES[key];
const checked = activeFilters.indexOf(key) !== -1 ? 'checked' : '';
const count = counts[key] || 0;
html += '' +
'<label style="display:flex;align-items:center;gap:8px;margin-bottom:6px;cursor:pointer;">' +
'<input type="checkbox" value="' + key + '" ' + checked + ' onchange="toggleCategoryFilter(this)">' +
'<span>' + categoryIcon(cat) + ' ' + cat.label + '</span>' +
'</label>';
html += '<label style="display:flex;align-items:center;gap:8px;margin-bottom:6px;cursor:pointer;font-size:0.85rem;color:var(--color-text-secondary)">' +
'<input type="checkbox" value="' + key + '" ' + checked + ' onchange="toggleCategoryFilter(this)">' +
categoryIcon(cat) +
'<span>' + cat.label + ' (' + count + ')</span>' +
'</label>';
}
html += '<p style="margin-top:10px;font-size:0.85rem;color:var(--color-text-secondary)"><strong>' + total + '</strong> Beiträge insgesamt</p>';
container.innerHTML = html;
}
@@ -892,34 +903,6 @@ function toggleCategoryFilter(checkbox) {
updateContributionsList();
}
// Updates Statistics in Home Tab
function updateStatistics() {
const container = document.getElementById('stats-container');
const total = contributionsData.length;
// Counts per Category
const counts = {};
contributionsData.forEach(function (f) {
const cat = f.properties.category;
counts[cat] = (counts[cat] || 0) + 1;
});
let html = '<p style="font-size:0.9rem;"><strong>' + total + '</strong> Beiträge insgesamt</p>';
for (const key in CATEGORIES) {
const cat = CATEGORIES[key];
const count = counts[key] || 0;
if (count > 0) {
html += '<div style="display:flex;align-items:center;gap:8px;margin:4px 0;font-size:0.85rem;">' +
categoryIcon(cat) + ' ' +
cat.label + ': ' + count +
'</div>';
}
}
container.innerHTML = html;
}
// =====================================================================
// Block 13: Modals — Welcome, Login, Info, Privacy, Imprint
@@ -1034,7 +1017,7 @@ function escapeHtml(text) {
// Returns a colored Font Awesome Icon HTML String for a Category
function categoryIcon(cat) {
return '<i class="fa-solid ' + cat.faIcon + '" style="color:' + cat.color + ';"></i>';
return '<i class="fa-solid ' + cat.faIcon + ' fa-fw" style="color:' + cat.color + ';"></i>';
}
// Reverse Geocodes Coordinates and saves Address to Contribution via API