- Fixed calendar_scripts.html to wait for DOM ready before initialization - Added retry logic if widget not found on first attempt - Changed integration fallback: show ALL events when no calendars configured - Changed behavior: if no calendars selected, show all events (legacy mode) - This ensures backward compatibility with existing events User feedback: Integration wasn't initializing on page load, button '+' didn't work. Solution: Auto-init with retry + always show events (no empty state).
40 lines
1.4 KiB
HTML
40 lines
1.4 KiB
HTML
{% load static %}
|
||
{# === JavaScript инициализация календаря === #}
|
||
|
||
<script type="module">
|
||
import { initCalendarWidget } from '{% static "js/components/calendarWidget.js" %}';
|
||
import { integrateCalendarManager } from '{% static "js/components/calendarWidgetIntegration.js" %}';
|
||
|
||
// Функция инициализации интеграции
|
||
function initializeIntegration() {
|
||
// Проверяем, есть ли уже виджет
|
||
const widget = window.calendarWidget || initCalendarWidget();
|
||
|
||
if (widget) {
|
||
window.calendarWidget = widget;
|
||
|
||
// Интеграция с менеджером календарей
|
||
const integration = integrateCalendarManager(widget);
|
||
if (integration) {
|
||
window.calendarIntegration = integration;
|
||
console.log('[Calendar] Integration initialized with multiple calendars support');
|
||
} else {
|
||
console.warn('[Calendar] Integration failed to initialize');
|
||
}
|
||
} else {
|
||
console.warn('[Calendar] Widget not found, retrying in 500ms...');
|
||
setTimeout(initializeIntegration, 500);
|
||
}
|
||
}
|
||
|
||
// Инициализация после загрузки DOM
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', initializeIntegration);
|
||
} else {
|
||
// DOM уже загружен
|
||
initializeIntegration();
|
||
}
|
||
</script>
|
||
|
||
|