replaced inline javascript in admin.php with admin.js

This commit is contained in:
2026-04-30 16:56:05 +02:00
parent 5bfdda2340
commit bd576665c8
3 changed files with 27 additions and 651 deletions

View File

@@ -7,6 +7,12 @@
// Depends on: ADMIN_CONFIG Object set in Moderation Page
// =====================================================================
// =====================================================================
// Block 0: Configuration and Application State
// =====================================================================
// API Endpoint as relative Path
const API_URL = 'api/contributions.php';
// =====================================================================
// Block 1: Page Tab Navigation
@@ -112,10 +118,10 @@ function loadMapPreview(mapDiv) {
// Fetches all Contributions to find the Geometry
const formData = new FormData();
formData.append('action', 'read');
formData.append('municipality_id', ADMIN_CONFIG.municipalityId);
formData.append('municipality_id', ADMIN_CONFIG.id);
formData.append('status', 'all');
fetch(ADMIN_CONFIG.apiUrl, { method: 'POST', body: formData })
fetch(API_URL, { method: 'POST', body: formData })
.then(function (r) { return r.json(); })
.then(function (data) {
if (!data.features) return;
@@ -165,7 +171,7 @@ function loadMapPreview(mapDiv) {
if (bounds.isValid()) {
miniMap.fitBounds(bounds, { padding: [25, 25], maxZoom: 17 });
} else {
miniMap.setView(ADMIN_CONFIG.municipalityCenter, 15);
miniMap.setView(ADMIN_CONFIG.center, 15);
}
mapDiv.dataset.loaded = 'true';
@@ -280,7 +286,7 @@ function apiCall(data) {
formData.append(key, data[key]);
}
return fetch(ADMIN_CONFIG.apiUrl, { method: 'POST', body: formData })
return fetch(API_URL, { method: 'POST', body: formData })
.then(function (r) { return r.json(); });
}
@@ -536,7 +542,7 @@ function createNews() {
apiCall({
action: 'create_news',
municipality_id: ADMIN_CONFIG.municipalityId,
municipality_id: ADMIN_CONFIG.id,
title: result.value.title,
content: result.value.content,
author_name: result.value.author_name