26 Commits

Author SHA1 Message Date
13a1f50134 news sort control in sidebar 2026-06-16 16:58:25 +02:00
7e9c8cd60d news sort control in sidebar 2026-06-16 16:58:15 +02:00
2aae2cd518 contribution sort control in sidebar 2026-06-16 16:35:49 +02:00
286026d7ba polished sidebar design 2026-06-16 16:32:56 +02:00
5aa1fbf13c contribution sort control in sidebar 2026-06-16 16:27:56 +02:00
36ef947be0 redesigned category filter in sidebar 2026-06-16 16:24:11 +02:00
cf09e88a5b custom edit and create modals 2026-06-16 16:06:25 +02:00
70fe829e97 cutom edit contribution modal 2026-06-16 15:53:42 +02:00
c1dd6cc009 replaced sweet alert inline styles with CSS classes 2026-06-16 15:43:48 +02:00
336e7cf3a6 moved add news button 2026-06-16 15:32:39 +02:00
6898a837e8 adapted sweet alert styles to design theme 2026-06-16 15:19:00 +02:00
a859e61483 replaced sweet alert inline styles with CSS classes 2026-06-16 15:15:18 +02:00
3fa47a3347 developer notice colour in modals 2026-06-16 15:10:54 +02:00
7c0a17c915 added utility designs 2026-06-16 15:05:25 +02:00
59147deec6 added utility designs 2026-06-16 15:00:20 +02:00
d5efbc02d2 added utility designs 2026-06-16 14:58:19 +02:00
60d6b9e4b6 added utility designs 2026-06-16 14:57:52 +02:00
ee84734601 replaced inline styles with CSS classes 2026-06-16 14:42:57 +02:00
2bfb245a46 added utility designs 2026-06-16 14:34:05 +02:00
90dc71e1c3 added design tokens for fonds, radiuses, shadows and spacings 2026-06-16 14:27:53 +02:00
35caac394c fixed sidebar colours 2026-06-12 13:36:22 +02:00
bb855d1510 removed leaflet flag 2026-06-12 13:30:11 +02:00
59b9440420 layer control redesign 2026-06-12 13:16:42 +02:00
649a2bab9c removed scale bar 2026-06-12 12:59:50 +02:00
9f8312b88b larger close button for popups 2026-06-12 12:49:03 +02:00
e1204cd311 moved sweet alert message above login modal 2026-06-12 12:46:20 +02:00
5 changed files with 852 additions and 423 deletions

View File

@@ -228,7 +228,7 @@ $counts['total'] = count($all_contributions);
<div id="contributions-container">
<?php if (empty($all_contributions)): ?>
<div class="empty-state">
<i class="fa-solid fa-inbox" style="font-size:2rem;margin-bottom:8px;display:block;"></i>
<i class="fa-solid fa-inbox"></i>
Noch keine Beiträge vorhanden.
</div>
<?php else: ?>
@@ -334,9 +334,9 @@ $counts['total'] = count($all_contributions);
<i class="fa-solid fa-trash"></i> Löschen
</button>
<a class="btn btn-map" href="index.php" target="_blank">
<!-- <a class="btn btn-map" href="index.php" target="_blank">
<i class="fa-solid fa-map-location-dot"></i> Karte
</a>
</a> -->
</div>
</div>
</div>
@@ -381,7 +381,7 @@ $counts['total'] = count($all_contributions);
<div id="comments-mod-container">
<?php if (empty($all_comments)): ?>
<div class="empty-state">
<i class="fa-solid fa-comments" style="font-size:2rem;margin-bottom:8px;display:block;"></i>
<i class="fa-solid fa-comments"></i>
Noch keine Kommentare vorhanden.
</div>
<?php else: ?>
@@ -409,9 +409,9 @@ $counts['total'] = count($all_contributions);
<!-- Expanded Detail -->
<div class="contribution-row-detail">
<div style="padding:12px 0;">
<div>
<!-- Comment Content -->
<div style="font-size:0.9rem;line-height:1.6;color:var(--color-text);margin-bottom:12px;">
<div class="detail-block">
<?= nl2br(htmlspecialchars($comment['content'])) ?>
</div>
<!-- Meta -->
@@ -457,25 +457,37 @@ $counts['total'] = count($all_contributions);
<!-- News Article Tab -->
<!-- ========================================================= -->
<div id="tab-news" class="page-tab-content" style="display:none;">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;">
<h2 style="margin:0;border:none;padding:0;"><i class="fa-solid fa-newspaper"></i> Neuigkeiten</h2>
<button class="btn btn-approve" onclick="createNews()">
<i class="fa-solid fa-plus"></i> Nachricht hinzufügen
<!-- Filter -->
<div class="filter-tabs" id="news-filter-tabs">
<button class="filter-tab active" onclick="filterNewsByStatus('all', this)">
Alle <span class="tab-count"><?= count($news_items) ?></span>
</button>
</div>
<!-- Sort Controls -->
<div class="sort-controls">
<span id="news-visible-count"><?= count($news_items) ?> Neuigkeiten</span>
<div style="display:flex;gap:var(--space-sm);align-items:center;">
<select onchange="sortNewsRows(this.value)">
<option value="date-desc">Neueste zuerst</option>
<option value="date-asc">Älteste zuerst</option>
</select>
</div>
</div>
<?php if (empty($news_items)): ?>
<div class="empty-state">
<i class="fa-solid fa-newspaper" style="font-size:2rem;margin-bottom:8px;display:block;"></i>
<i class="fa-solid fa-newspaper"></i>
Noch keine Neuigkeiten veröffentlicht.
</div>
<?php else: ?>
<?php foreach ($news_items as $news): ?>
<div class="contribution-row" data-id="<?= $news['news_id'] ?>">
<div class="contribution-row" data-id="<?= $news['news_id'] ?>" data-date="<?= $news['published_at'] ?>">
<div class="contribution-row-header" onclick="toggleRow(this.parentElement)">
<div class="contribution-row-summary">
<span class="title"><?= htmlspecialchars($news['title']) ?></span>
<span style="font-size:0.8rem;color:#999;">
<span class="detail-block-meta">
<?= date('d.m.Y', strtotime($news['published_at'])) ?>
· <?= htmlspecialchars($news['author_name']) ?>
</span>
@@ -483,7 +495,7 @@ $counts['total'] = count($all_contributions);
<i class="fa-solid fa-chevron-down collapse-icon"></i>
</div>
<div class="contribution-row-detail">
<div style="padding:12px 0;font-size:0.9rem;line-height:1.6;color:#5a5a7a;">
<div class="detail-block">
<?= nl2br(htmlspecialchars($news['content'])) ?>
</div>
<div class="action-buttons">
@@ -498,6 +510,12 @@ $counts['total'] = count($all_contributions);
</div>
<?php endforeach; ?>
<?php endif; ?>
<div class="tab-footer-action">
<button class="btn btn-approve" onclick="createNews()">
<i class="fa-solid fa-plus"></i> Neuigkeit hinzufügen
</button>
</div>
</div>
@@ -521,6 +539,74 @@ $counts['total'] = count($all_contributions);
</div>
<!-- ============================================================= -->
<!-- Edit Contribution Modal (Admin) -->
<!-- ============================================================= -->
<div id="admin-edit-modal" class="modal-overlay" style="display:none;">
<div class="modal-content">
<h2><i class="fa-solid fa-pen"></i> Beitrag bearbeiten</h2>
<div class="form-group">
<label for="admin-edit-title">Titel</label>
<input type="text" id="admin-edit-title" class="form-input">
</div>
<div class="form-group">
<label for="admin-edit-description">Beschreibung</label>
<textarea id="admin-edit-description" class="form-input" rows="4"></textarea>
</div>
<input type="hidden" id="admin-edit-id">
<div class="modal-actions">
<button class="btn btn-secondary" onclick="closeAdminModal('admin-edit-modal')">Abbrechen</button>
<button class="btn btn-primary" onclick="submitAdminEdit()">Speichern</button>
</div>
</div>
</div>
<!-- ============================================================= -->
<!-- Edit Comment Modal (Admin) -->
<!-- ============================================================= -->
<div id="admin-comment-modal" class="modal-overlay" style="display:none;">
<div class="modal-content">
<h2><i class="fa-solid fa-pen"></i> Kommentar bearbeiten</h2>
<div class="form-group">
<label for="admin-comment-content">Inhalt</label>
<textarea id="admin-comment-content" class="form-input" rows="4"></textarea>
</div>
<input type="hidden" id="admin-comment-id">
<div class="modal-actions">
<button class="btn btn-secondary" onclick="closeAdminModal('admin-comment-modal')">Abbrechen</button>
<button class="btn btn-primary" onclick="submitAdminComment()">Speichern</button>
</div>
</div>
</div>
<!-- ============================================================= -->
<!-- Create/Edit News Modal (Admin) -->
<!-- ============================================================= -->
<div id="admin-news-modal" class="modal-overlay" style="display:none;">
<div class="modal-content">
<h2 id="admin-news-modal-title"><i class="fa-solid fa-newspaper"></i> Neuigkeit hinzufügen</h2>
<div class="form-group">
<label for="admin-news-title">Titel</label>
<input type="text" id="admin-news-title" class="form-input" placeholder="Titel der Neuigkeit">
</div>
<div class="form-group">
<label for="admin-news-content">Inhalt</label>
<textarea id="admin-news-content" class="form-input" rows="4" placeholder="Neuigkeit verfassen..."></textarea>
</div>
<div class="form-group">
<label for="admin-news-author">Autor</label>
<input type="text" id="admin-news-author" class="form-input" value="Stadtverwaltung">
</div>
<input type="hidden" id="admin-news-id">
<input type="hidden" id="admin-news-mode">
<div class="modal-actions">
<button class="btn btn-secondary" onclick="closeAdminModal('admin-news-modal')">Abbrechen</button>
<button class="btn btn-primary" onclick="submitAdminNews()">Speichern</button>
</div>
</div>
</div>
<!-- ============================================================= -->
<!-- Loads JavaScript Dependencies -->
<!-- ============================================================= -->

View File

@@ -167,6 +167,16 @@ $news_items = $stmt->fetchAll();
<div class="list-search">
<input type="text" id="list-search-input" placeholder="Beiträge durchsuchen..." class="form-input">
</div>
<div class="list-controls">
<select id="list-sort" class="form-input list-sort-select" onchange="updateContributionsList()">
<option value="date-desc">Neueste zuerst</option>
<option value="date-asc">Älteste zuerst</option>
<option value="category">Nach Kategorie</option>
<option value="likes">Meiste Bewertungen</option>
<option value="comments">Meiste Kommentare</option>
</select>
<span id="list-count" class="list-count"></span>
</div>
<div id="contributions-list">
<!-- Contribution Cards — populated by app.js -->
</div>
@@ -185,6 +195,14 @@ $news_items = $stmt->fetchAll();
<input type="text" id="news-search-input" placeholder="Neuigkeiten durchsuchen..." class="form-input" oninput="filterNews()">
</div>
<div class="list-controls">
<select id="news-sort" class="form-input list-sort-select" onchange="sortNews()">
<option value="date-desc">Neueste zuerst</option>
<option value="date-asc">Älteste zuerst</option>
</select>
<span class="list-count"><?= count($news_items) ?> Neuigkeiten</span>
</div>
<!-- News Items Container -->
<div id="news-list">
<?php if (empty($news_items)): ?>
@@ -194,7 +212,8 @@ $news_items = $stmt->fetchAll();
<div class="news-item"
data-title="<?= htmlspecialchars(strtolower($news['title'])) ?>"
data-content="<?= htmlspecialchars(strtolower($news['content'])) ?>"
data-author="<?= htmlspecialchars(strtolower($news['author_name'])) ?>">
data-author="<?= htmlspecialchars(strtolower($news['author_name'])) ?>"
data-date="<?= $news['published_at'] ?>">
<h3><?= htmlspecialchars($news['title']) ?></h3>
<p><?= nl2br(htmlspecialchars($news['content'])) ?></p>
<span class="news-date">
@@ -218,7 +237,7 @@ $news_items = $stmt->fetchAll();
<h3><i class="fa-solid fa-book"></i> Interaktive Anleitung</h3>
<p>Klicken Sie unten auf Tutorial starten um Schritt für Schritt durch die Kernfunktionen der Mitmachkarte geführt zu werden.</p>
<p>
<button class="btn btn-primary" onclick="if(typeof restartOnboarding==='function'){sidebar.close();restartOnboarding()}" style="font-size:0.85rem;">
<button class="btn btn-primary" onclick="if(typeof restartOnboarding==='function'){sidebar.close();restartOnboarding()}">
<i class="fa-solid fa-route"></i> Tutorial starten
</button>
</p>
@@ -274,7 +293,7 @@ $news_items = $stmt->fetchAll();
<li>Hinweise und Verbesserungsvorschläge für die Stadtverwaltung hinzufügen</li>
<li>Bestehende Beiträge der Bürgerschaft betrachten und bewerten</li>
</ul>
<p style="background:#fff3cd;padding:10px;border-radius:6px;border:1px solid #ffc107;font-size:0.85rem;color:#856404;">
<p class="dev-notice">
<i class="fa-solid fa-triangle-exclamation"></i> <strong>Hinweis:</strong> Demoversion - nicht in Rücksprache mit der Stadt Lohne entwickelt! Alle Beitrage, Kommentare und Personen sind frei erfunden.
</p>
<p>Zum Hinzufügen von Beiträgen geben Sie bitte zunächst Ihren Namen ein.</p> <div class="modal-actions">
@@ -349,6 +368,33 @@ $news_items = $stmt->fetchAll();
</div>
<!-- ============================================================= -->
<!-- Edit Contribution Modal -->
<!-- ============================================================= -->
<div id="edit-modal" class="modal-overlay" style="display:none;">
<div class="modal-content">
<h2><i class="fa-solid fa-pen"></i> Beitrag bearbeiten</h2>
<div class="form-group">
<label for="edit-title">Titel</label>
<input type="text" id="edit-title" class="form-input">
</div>
<div class="form-group">
<label for="edit-description">Beschreibung</label>
<textarea id="edit-description" class="form-input" rows="4"></textarea>
</div>
<input type="hidden" id="edit-contribution-id">
<div class="modal-actions">
<button class="btn btn-secondary" onclick="closeEditModal()">Abbrechen</button>
<button class="btn btn-primary" onclick="submitEdit()">Speichern</button>
</div>
</div>
</div>
<!-- ============================================================= -->
<!-- Loads JavaScript Dependencies -->
<!-- ============================================================= -->

View File

@@ -132,7 +132,7 @@ function loadMapPreview(mapDiv) {
});
if (!feature) {
mapDiv.innerHTML = '<div style="padding:20px;color:#999;text-align:center;font-size:0.8rem;">Geometrie nicht gefunden.</div>';
mapDiv.innerHTML = '<div class="empty-state">Geometrie nicht gefunden.</div>';
return;
}
@@ -177,7 +177,7 @@ function loadMapPreview(mapDiv) {
mapDiv.dataset.loaded = 'true';
})
.catch(function () {
mapDiv.innerHTML = '<div style="padding:20px;color:#999;text-align:center;font-size:0.8rem;">Karte nicht verfügbar.</div>';
mapDiv.innerHTML = '<div class="empty-state">Karte nicht verfügbar.</div>';
});
}
@@ -275,7 +275,26 @@ function sortCommentRows(sortBy) {
// =====================================================================
// Block 7: Helper Functions
// Block 7: News Filter and Sorting
// =====================================================================
// Sorts News
function sortNewsRows(sortBy) {
var container = document.getElementById('tab-news');
var rows = Array.from(container.querySelectorAll('.contribution-row'));
rows.sort(function (a, b) {
if (sortBy === 'date-desc') return new Date(b.dataset.date || 0) - new Date(a.dataset.date || 0);
if (sortBy === 'date-asc') return new Date(a.dataset.date || 0) - new Date(b.dataset.date || 0);
return 0;
});
rows.forEach(function (row) { row.parentNode.appendChild(row); });
}
// =====================================================================
// Block 8: Helper Functions
// =====================================================================
// Sends a POST request to API
@@ -300,8 +319,24 @@ function escapeHtml(text) {
return div.innerHTML;
}
// Closes Admin Modals by ID
function closeAdminModal(modalId) {
document.getElementById(modalId).style.display = 'none';
}
// Closes Admin Modals on Escape Key
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') {
document.querySelectorAll('.modal-overlay').forEach(function (modal) {
modal.style.display = 'none';
});
}
});
// =====================================================================
// Block 8: CRUD Operations for Contributions
// Block 9: CRUD Operations for Contributions
// =====================================================================
// STATUS: Changes Contribution Status
@@ -335,46 +370,37 @@ function changeStatus(contributionId, newStatus) {
// UPDATE: Edits existing Contributions
function editContribution(contributionId, currentTitle, currentDescription) {
Swal.fire({
title: 'Beitrag bearbeiten',
html:
'<div style="text-align:left;">' +
'<div style="margin-bottom:12px;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
'<input id="swal-title" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(currentTitle) + '">' +
'</div>' +
'<div>' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Beschreibung</label>' +
'<textarea id="swal-description" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(currentDescription) + '</textarea>' +
'</div>' +
'</div>',
showCancelButton: true,
confirmButtonText: 'Speichern',
cancelButtonText: 'Abbrechen',
confirmButtonColor: ADMIN_CONFIG.primaryColor,
preConfirm: function () {
return {
title: document.getElementById('swal-title').value.trim(),
description: document.getElementById('swal-description').value.trim()
};
document.getElementById('admin-edit-id').value = contributionId;
document.getElementById('admin-edit-title').value = currentTitle;
document.getElementById('admin-edit-description').value = currentDescription;
document.getElementById('admin-edit-modal').style.display = 'flex';
}
// Submits Edit from Custom Modal
function submitAdminEdit() {
var id = document.getElementById('admin-edit-id').value;
var title = document.getElementById('admin-edit-title').value.trim();
var description = document.getElementById('admin-edit-description').value.trim();
if (!title) {
Swal.fire('Titel fehlt', 'Bitte geben Sie einen Titel ein.', 'warning');
return;
}
}).then(function (result) {
if (!result.isConfirmed) return;
apiCall({
action: 'update',
contribution_id: contributionId,
title: result.value.title,
description: result.value.description
contribution_id: id,
title: title,
description: description
}).then(function (response) {
if (response.error) {
Swal.fire('Fehler', response.error, 'error');
return;
}
closeAdminModal('admin-edit-modal');
Swal.fire('Gespeichert!', 'Beitrag wurde aktualisiert.', 'success')
.then(function () { location.reload(); });
});
});
}
@@ -387,7 +413,7 @@ function deleteContribution(contributionId) {
showCancelButton: true,
confirmButtonText: 'Beitrag löschen',
cancelButtonText: 'Abbrechen',
confirmButtonColor: '#c62828'
customClass: { confirmButton: 'swal-btn-danger' },
}).then(function (result) {
if (!result.isConfirmed) return;
@@ -406,7 +432,7 @@ function deleteContribution(contributionId) {
}
// =====================================================================
// Block 9: CRUD Operations for Comments
// Block 10: CRUD Operations for Comments
// =====================================================================
// STATUS: Changes Comment Status
@@ -439,36 +465,34 @@ function changeCommentStatus(commentId, newStatus) {
// UPDATE: Edits existing Comments
function editModComment(commentId, currentContent) {
Swal.fire({
title: 'Kommentar bearbeiten',
html:
'<div style="text-align:left;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
'<textarea id="swal-comment-content" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(currentContent) + '</textarea>' +
'</div>',
showCancelButton: true,
confirmButtonText: 'Speichern',
cancelButtonText: 'Abbrechen',
confirmButtonColor: ADMIN_CONFIG.primaryColor,
preConfirm: function () {
return { content: document.getElementById('swal-comment-content').value.trim() };
document.getElementById('admin-comment-id').value = commentId;
document.getElementById('admin-comment-content').value = currentContent;
document.getElementById('admin-comment-modal').style.display = 'flex';
}
// Submits Comment Edit from Custom Modal
function submitAdminComment() {
var id = document.getElementById('admin-comment-id').value;
var content = document.getElementById('admin-comment-content').value.trim();
if (!content) {
Swal.fire('Inhalt fehlt', 'Bitte geben Sie einen Inhalt ein.', 'warning');
return;
}
}).then(function (result) {
if (!result.isConfirmed) return;
apiCall({
action: 'update_comment',
comment_id: commentId,
content: result.value.content
comment_id: id,
content: content
}).then(function (response) {
if (response.error) {
Swal.fire('Fehler', response.error, 'error');
return;
}
closeAdminModal('admin-comment-modal');
Swal.fire('Gespeichert!', 'Kommentar wurde aktualisiert.', 'success')
.then(function () { location.reload(); });
});
});
}
@@ -481,7 +505,7 @@ function deleteModComment(commentId) {
showCancelButton: true,
confirmButtonText: 'Löschen',
cancelButtonText: 'Abbrechen',
confirmButtonColor: '#c62828'
customClass: { confirmButton: 'swal-btn-danger' },
}).then(function (result) {
if (!result.isConfirmed) return;
@@ -501,111 +525,72 @@ function deleteModComment(commentId) {
// =====================================================================
// Block 10: CRUD Operations for News
// Block 11: CRUD Operations for News
// =====================================================================
// CREATE: Submits new News Article
// CREATE: Creates News
function createNews() {
Swal.fire({
title: 'Neuigkeit hinzufügen',
html:
'<div style="text-align:left;">' +
'<div style="margin-bottom:12px;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
'<input id="swal-news-title" class="swal2-input" style="margin:0;width:100%;" placeholder="Titel der Neuigkeit">' +
'</div>' +
'<div style="margin-bottom:12px;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
'<textarea id="swal-news-content" class="swal2-textarea" style="margin:0;width:100%;" placeholder="Neuigkeit verfassen..."></textarea>' +
'</div>' +
'<div>' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Autor</label>' +
'<input id="swal-news-author" class="swal2-input" style="margin:0;width:100%;" value="Stadtverwaltung">' +
'</div>' +
'</div>',
showCancelButton: true,
confirmButtonText: 'Veröffentlichen',
cancelButtonText: 'Abbrechen',
confirmButtonColor: ADMIN_CONFIG.primaryColor,
preConfirm: function () {
const title = document.getElementById('swal-news-title').value.trim();
const content = document.getElementById('swal-news-content').value.trim();
const author = document.getElementById('swal-news-author').value.trim() || 'Stadtverwaltung';
if (!title || !content) {
Swal.showValidationMessage('Titel und Inhalt sind Pflichtfelder.');
return false;
}
return { title, content, author_name: author };
}
}).then(function (result) {
if (!result.isConfirmed) return;
apiCall({
action: 'create_news',
municipality_id: ADMIN_CONFIG.id,
title: result.value.title,
content: result.value.content,
author_name: result.value.author_name
}).then(function (response) {
if (response.error) {
Swal.fire('Fehler', response.error, 'error');
return;
}
Swal.fire('Veröffentlicht!', 'Neuigkeit wurde veröffentlicht.', 'success')
.then(function () { location.reload(); });
});
});
document.getElementById('admin-news-modal-title').innerHTML = '<i class="fa-solid fa-newspaper"></i> Neuigkeit hinzufügen';
document.getElementById('admin-news-id').value = '';
document.getElementById('admin-news-mode').value = 'create';
document.getElementById('admin-news-title').value = '';
document.getElementById('admin-news-content').value = '';
document.getElementById('admin-news-author').value = 'Stadtverwaltung';
document.getElementById('admin-news-modal').style.display = 'flex';
}
// UPDATE: Edits existing News
function editNews(newsId, currentTitle, currentContent, currentAuthor) {
Swal.fire({
title: 'Neuigkeit bearbeiten',
html:
'<div style="text-align:left;">' +
'<div style="margin-bottom:12px;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
'<input id="swal-news-title" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(currentTitle) + '">' +
'</div>' +
'<div style="margin-bottom:12px;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
'<textarea id="swal-news-content" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(currentContent) + '</textarea>' +
'</div>' +
'<div>' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Autor</label>' +
'<input id="swal-news-author" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(currentAuthor) + '">' +
'</div>' +
'</div>',
showCancelButton: true,
confirmButtonText: 'Speichern',
cancelButtonText: 'Abbrechen',
confirmButtonColor: ADMIN_CONFIG.primaryColor,
preConfirm: function () {
return {
title: document.getElementById('swal-news-title').value.trim(),
content: document.getElementById('swal-news-content').value.trim(),
author_name: document.getElementById('swal-news-author').value.trim() || 'Stadtverwaltung'
document.getElementById('admin-news-modal-title').innerHTML = '<i class="fa-solid fa-pen"></i> Neuigkeit bearbeiten';
document.getElementById('admin-news-id').value = newsId;
document.getElementById('admin-news-mode').value = 'edit';
document.getElementById('admin-news-title').value = currentTitle;
document.getElementById('admin-news-content').value = currentContent;
document.getElementById('admin-news-author').value = currentAuthor;
document.getElementById('admin-news-modal').style.display = 'flex';
}
// Submits News from Custom Modal (Create or Edit)
function submitAdminNews() {
var mode = document.getElementById('admin-news-mode').value;
var title = document.getElementById('admin-news-title').value.trim();
var content = document.getElementById('admin-news-content').value.trim();
var author = document.getElementById('admin-news-author').value.trim() || 'Stadtverwaltung';
if (!title || !content) {
Swal.fire('Pflichtfelder', 'Titel und Inhalt sind Pflichtfelder.', 'warning');
return;
}
var data;
if (mode === 'create') {
data = {
action: 'create_news',
municipality_id: ADMIN_CONFIG.id,
title: title,
content: content,
author_name: author
};
} else {
data = {
action: 'update_news',
news_id: document.getElementById('admin-news-id').value,
title: title,
content: content,
author_name: author
};
}
}).then(function (result) {
if (!result.isConfirmed) return;
apiCall({
action: 'update_news',
news_id: newsId,
title: result.value.title,
content: result.value.content,
author_name: result.value.author_name
}).then(function (response) {
apiCall(data).then(function (response) {
if (response.error) {
Swal.fire('Fehler', response.error, 'error');
return;
}
Swal.fire('Gespeichert!', 'Neuigkeit wurde aktualisiert.', 'success')
closeAdminModal('admin-news-modal');
var msg = mode === 'create' ? 'Neuigkeit wurde veröffentlicht.' : 'Neuigkeit wurde aktualisiert.';
Swal.fire('Gespeichert!', msg, 'success')
.then(function () { location.reload(); });
});
});
}
@@ -618,7 +603,7 @@ function deleteNews(newsId) {
showCancelButton: true,
confirmButtonText: 'Löschen',
cancelButtonText: 'Abbrechen',
confirmButtonColor: '#c62828'
customClass: { confirmButton: 'swal-btn-danger' },
}).then(function (result) {
if (!result.isConfirmed) return;

View File

@@ -88,9 +88,9 @@ basemapCartoDB.addTo(map);
// Layer Control
const basemaps = {
'<i class="fa-solid fa-map" style="color:#404040;"></i> Hintergrundkarte (farbe)': basemapOSM,
'<i class="fa-solid fa-map" style="color:#404040;"></i> Hintergrundkarte (grau)': basemapCartoDB,
'<i class="fa-solid fa-satellite" style="color:#404040;"></i> Satellitenbild': basemapSatellite,
// 'Hintergrundkarte': basemapOSM,
'Hintergrundkarte': basemapCartoDB,
'Satellitenbild': basemapSatellite,
};
const overlays = {}; // Populated later with Contribution Layers
@@ -100,6 +100,16 @@ const layerControl = L.control.layers(basemaps, overlays, {
collapsed: true
}).addTo(map);
// Adds styled Header to Layer Control Dropdown
var layerControlContainer = layerControl.getContainer();
var layerList = layerControlContainer.querySelector('.leaflet-control-layers-list');
if (layerList) {
var header = document.createElement('div');
header.className = 'layer-control-header';
header.innerHTML = '<i class="fa-solid fa-layer-group"></i> Layerauswahl';
layerList.parentNode.insertBefore(header, layerList);
}
// =====================================================================
// Block 4: Map Controls
@@ -111,11 +121,11 @@ L.control.zoom({
}).addTo(map);
// Scale Bar
L.control.scale({
position: 'bottomright',
maxWidth: 200,
imperial: false
}).addTo(map);
// L.control.scale({
// position: 'bottomright',
// maxWidth: 200,
// imperial: false
// }).addTo(map);
// Fullscreen Button
L.control.fullscreen({
@@ -392,7 +402,7 @@ function loadContributions() {
onEachFeature: bindFeaturePopup
}).addTo(map);
layerControl.addOverlay(contributionsLayer, '<i class="fa-solid fa-map-pin" style="color:#C00000;"></i> Beiträge');
layerControl.addOverlay(contributionsLayer, 'Bürgerbeiträge');
// Update Sidebar List and Statistics
updateContributionsList();
buildCategoryFilter();
@@ -643,56 +653,53 @@ function closeCreateModal() {
}
// UPDATE: Edits existing Contributions
// UPDATE: Opens Edit Modal for existing Contributions
function editContribution(contributionId) {
// Finds Contribution in local Data
const contribution = contributionsData.find(function (f) {
return f.properties.contribution_id === contributionId;
});
if (!contribution) return;
const props = contribution.properties;
document.getElementById('edit-contribution-id').value = contributionId;
document.getElementById('edit-title').value = props.title;
document.getElementById('edit-description').value = props.description || '';
document.getElementById('edit-modal').style.display = 'flex';
}
Swal.fire({
title: 'Beitrag bearbeiten',
html:
'<div style="text-align:left;">' +
'<div style="margin-bottom:12px;">' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
'<input id="swal-title" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(props.title) + '">' +
'</div>' +
'<div>' +
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Beschreibung</label>' +
'<textarea id="swal-description" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(props.description || '') + '</textarea>' +
'</div>' +
'</div>',
showCancelButton: true,
confirmButtonText: 'Speichern',
cancelButtonText: 'Abbrechen',
confirmButtonColor: MUNICIPALITY.primaryColor,
preConfirm: function () {
return {
title: document.getElementById('swal-title').value.trim(),
description: document.getElementById('swal-description').value.trim()
};
// Submits Edit from Custom Modal
function submitEdit() {
const contributionId = document.getElementById('edit-contribution-id').value;
const title = document.getElementById('edit-title').value.trim();
const description = document.getElementById('edit-description').value.trim();
if (!title) {
Swal.fire('Titel fehlt', 'Bitte geben Sie einen Titel ein.', 'warning');
return;
}
}).then(function (result) {
if (!result.isConfirmed) return;
apiCall({
action: 'update',
contribution_id: contributionId,
title: result.value.title,
description: result.value.description
title: title,
description: description
}, function (response) {
if (response.error) {
Swal.fire('Fehler', response.error, 'error');
return;
}
closeEditModal();
Swal.fire('Gespeichert!', 'Der Beitrag wurde aktualisiert.', 'success');
loadContributions();
});
});
}
// Closes Edit Modal
function closeEditModal() {
document.getElementById('edit-modal').style.display = 'none';
document.getElementById('edit-contribution-id').value = '';
document.getElementById('edit-title').value = '';
document.getElementById('edit-description').value = '';
}
// DELETE: Deletes existing Contributions
@@ -704,7 +711,7 @@ function deleteContribution(contributionId) {
showCancelButton: true,
confirmButtonText: 'Löschen',
cancelButtonText: 'Abbrechen',
confirmButtonColor: '#c62828'
customClass: { confirmButton: 'swal-btn-danger' },
}).then(function (result) {
if (!result.isConfirmed) return;
@@ -822,11 +829,25 @@ function updateContributionsList() {
return matchesCategory && matchesSearch;
});
// Sorts by Date (newest first)
// Sorts by selected Option
var sortBy = document.getElementById('list-sort') ? document.getElementById('list-sort').value : 'date-desc';
filtered.sort(function (a, b) {
return new Date(b.properties.created_at) - new Date(a.properties.created_at);
if (sortBy === 'date-desc') return new Date(b.properties.created_at) - new Date(a.properties.created_at);
if (sortBy === 'date-asc') return new Date(a.properties.created_at) - new Date(b.properties.created_at);
if (sortBy === 'likes') return b.properties.likes_count - a.properties.likes_count;
if (sortBy === 'comments') return (b.properties.comment_count || 0) - (a.properties.comment_count || 0);
if (sortBy === 'category') {
var catA = (CATEGORIES[a.properties.category] || CATEGORIES.other).label;
var catB = (CATEGORIES[b.properties.category] || CATEGORIES.other).label;
return catA.localeCompare(catB);
}
return 0;
});
// Updates Count Display
var countEl = document.getElementById('list-count');
if (countEl) countEl.textContent = filtered.length + ' Beiträge';
// Builds HTML
if (filtered.length === 0) {
container.innerHTML = '<p class="empty-state">Keine Beiträge gefunden.</p>';
@@ -911,14 +932,14 @@ function buildCategoryFilter() {
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;font-size:0.85rem;color:var(--color-text-secondary)">' +
html += '<label class="category-filter-label">' +
'<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>';
html += '<p class="category-filter-total"><strong>' + total + '</strong> Beiträge insgesamt</p>';
container.innerHTML = html;
}
@@ -1072,6 +1093,7 @@ document.addEventListener('keydown', function (e) {
document.getElementById('welcome-modal').style.display = 'none';
document.getElementById('login-modal').style.display = 'none';
document.getElementById('create-modal').style.display = 'none';
document.getElementById('edit-modal').style.display = 'none';
}
});
@@ -1137,6 +1159,21 @@ function filterNews() {
});
}
// Sorts News Items in Sidebar by Date
function sortNews() {
var sortBy = document.getElementById('news-sort').value;
var container = document.getElementById('news-list');
var items = Array.from(container.querySelectorAll('.news-item'));
items.sort(function (a, b) {
if (sortBy === 'date-desc') return new Date(b.dataset.date) - new Date(a.dataset.date);
if (sortBy === 'date-asc') return new Date(a.dataset.date) - new Date(b.dataset.date);
return 0;
});
items.forEach(function (item) { container.appendChild(item); });
}
// Loads and Displays Comments forContributions in Popups
function loadComments(contributionId) {
apiCall({

File diff suppressed because it is too large Load Diff