Neues Modal (js/ui/form.js) mit allen Feldern aus anforderung.md Abschnitt 6: Name, Kategorie, Kurz-/Volltext-Beschreibung, Adresse, Ort, Koordinaten, Altersgruppe, Kosten, Oeffnungszeiten, Aufenthaltsdauer, Ausstattungs-Checkboxen, Indoor/Outdoor, Bild-URL, Website, Tags. Validierung: Pflichtfelder (Name, Kategorie, Koordinaten), Koordinaten- Bereichspruefung, Alter min<=max, Bild-/Website-URL nur http/https. Fehler erscheinen inline je Feld (aria-invalid/aria-describedby), erstes fehlerhaftes Feld wird fokussiert. EventMap.ui.openPlaceForm(place) dient als Einstiegspunkt: ohne Argument zum Neuanlegen, mit Place-Objekt zum Bearbeiten. Speichern aktualisiert den Store mit neuer Array-Referenz (Karte/Liste reagieren automatisch) und persistiert nach LocalStorage. Verdrahtung: neuer "+ Neues Ausflugsziel hinzufuegen"-Button in der Karten-Toolbar; der bisherige Bearbeiten-Platzhalter in der Detailansicht (js/ui/detail.js) oeffnet jetzt das Formular vorausgefuellt mit dem aktuell angezeigten Ausflugsziel.
66 lines
1.8 KiB
JavaScript
66 lines
1.8 KiB
JavaScript
// Einstiegspunkt der Anwendung: initialisiert Store, Karte und Liste.
|
|
|
|
(function () {
|
|
const { initStore } = EventMap.store;
|
|
const { initMap, centerOnCoords, requestUserLocation } = EventMap.map;
|
|
const { initList, initDetail, initForm } = EventMap.ui;
|
|
|
|
function showFatalError(message) {
|
|
const status = document.getElementById('app-status');
|
|
if (!status) return;
|
|
status.textContent = message;
|
|
status.hidden = false;
|
|
}
|
|
|
|
function setupGeolocationButton() {
|
|
const button = document.getElementById('locate-btn');
|
|
if (!button) return;
|
|
|
|
const defaultLabel = button.textContent;
|
|
|
|
button.addEventListener('click', () => {
|
|
button.disabled = true;
|
|
button.textContent = 'Standort wird ermittelt…';
|
|
|
|
requestUserLocation({
|
|
onSuccess: ({ lat, lng }) => {
|
|
centerOnCoords(lat, lng, 13);
|
|
button.disabled = false;
|
|
button.textContent = defaultLabel;
|
|
},
|
|
onError: () => {
|
|
button.disabled = false;
|
|
button.textContent = defaultLabel;
|
|
showFatalError(
|
|
'Standort konnte nicht ermittelt werden. Bitte Standortfreigabe im Browser prüfen.'
|
|
);
|
|
},
|
|
});
|
|
});
|
|
}
|
|
|
|
function setupAddPlaceButton() {
|
|
const button = document.getElementById('add-place-btn');
|
|
if (!button) return;
|
|
|
|
button.addEventListener('click', () => {
|
|
EventMap.ui.openPlaceForm();
|
|
});
|
|
}
|
|
|
|
async function bootstrap() {
|
|
await initStore();
|
|
initMap('map');
|
|
initList('place-list');
|
|
initDetail('detail-modal');
|
|
initForm('place-form-modal');
|
|
setupGeolocationButton();
|
|
setupAddPlaceButton();
|
|
}
|
|
|
|
bootstrap().catch((err) => {
|
|
console.error('EventMap: Initialisierung fehlgeschlagen.', err);
|
|
showFatalError('Die Anwendung konnte nicht geladen werden. Bitte Seite neu laden.');
|
|
});
|
|
})();
|