replaced inline javascript in admin.php with admin.js
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user