refactor(calendar.html): change API URLs and event to occurrence

This commit is contained in:
2026-03-17 12:15:56 +01:00
parent f2a1534e63
commit 397336457f

View File

@@ -6,14 +6,14 @@
{% block extra_js %}
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.20/index.global.min.js" integrity="sha256-sQEgS6I+FEeOlX4oTVi7qW/HMRAh0O6vifpeZXIMRsg=" crossorigin="anonymous"></script>
<script>
function showModal(eventId) {
function showModal(occurrenceId) {
// get event's url
const eventApiUrl = `/api/calendar/events/${eventId}`;
const eventApiUrl = `/api/calendar/occurrences/${occurrenceId}`;
const eventApi = fetch(eventApiUrl)
.then(response => response.json())
.then(data => {
eventUrl = data.url;
eventUrl = `/occurrence/${occurrenceId}/`;
const modal = document.createElement('div');
modal.classList.add('fixed', 'inset-0', 'flex', 'items-center', 'justify-center', 'z-50', 'shadow-lg', 'overflow-auto');
@@ -41,7 +41,7 @@
if (e.target === modal) {
document.body.removeChild(modal);
// remove ?modal=eventId from the url
// remove ?modal=occurrenceId from the url
const url = new URL(window.location);
url.searchParams.delete('modal');
window.history.pushState({}, '', url);
@@ -55,7 +55,7 @@
document.body.removeChild(modal);
}
document.removeEventListener('keydown', escHandler);
// remove ?modal=eventId from the url
// remove ?modal=occurrenceId from the url
const url = new URL(window.location);
url.searchParams.delete('modal');
window.history.pushState({}, '', url);
@@ -69,16 +69,16 @@
if (document.body.contains(modal)) {
document.body.removeChild(modal);
}
// remove ?modal=eventId from the url
// remove ?modal=occurrenceId from the url
const url = new URL(window.location);
url.searchParams.delete('modal');
window.history.pushState({}, '', url);
});
modal.appendChild(closeButton);
// add ?modal=eventId to the url
// add ?modal=occurrenceId to the url
const url = new URL(window.location);
url.searchParams.set('modal', eventId);
url.searchParams.set('modal', occurrenceId);
window.history.pushState({}, '', url);
}
return data;
@@ -121,7 +121,7 @@
right: 'timeGridWeek,listMonth',
},
locale: "{% get_current_language as LANGUAGE_CODE %}{{ LANGUAGE_CODE }}",
events: "/api/calendar/events/",
events: "/api/calendar/occurrences/",
eventClick: function(info) {
// prevent default navigation
info.jsEvent.preventDefault();