From f8a8b3b2f2db03428b811f753601eb1640855307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Wed, 11 Feb 2026 11:26:25 +0300 Subject: [PATCH] fix(calendar): improve integration initialization and fallback to legacy mode - 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). --- backend/CONSOLE_DEBUG_COMMANDS.md | 207 +++++ backend/FIX_INTEGRATION.md | 60 ++ .../components/calendarWidgetIntegration.js | 13 +- .../includes/components/calendar_scripts.html | 37 +- backend/test_calendar_frontend.html | 758 ++++++++++++++++++ backend/test_calendar_frontend_simple.html | 720 +++++++++++++++++ 6 files changed, 1780 insertions(+), 15 deletions(-) create mode 100644 backend/CONSOLE_DEBUG_COMMANDS.md create mode 100644 backend/FIX_INTEGRATION.md create mode 100644 backend/test_calendar_frontend.html create mode 100644 backend/test_calendar_frontend_simple.html diff --git a/backend/CONSOLE_DEBUG_COMMANDS.md b/backend/CONSOLE_DEBUG_COMMANDS.md new file mode 100644 index 00000000..9b685c3c --- /dev/null +++ b/backend/CONSOLE_DEBUG_COMMANDS.md @@ -0,0 +1,207 @@ +# 🔍 Команды для отладки календаря через консоль браузера + +Откройте консоль браузера (F12 → Console) и выполните эти команды: + +## 1️⃣ Проверить наличие интеграции + +```javascript +// Должно вернуть объект, а не undefined +window.calendarIntegration +``` + +**Ожидаемый результат:** +```javascript +{ + fetchEventsForVisibleCalendars: ƒ, + getVisibleCalendarIds: ƒ, + getCalendars: ƒ, + setVisibleCalendars: ƒ, + refresh: ƒ, + instances: {manager: {...}, modal: {...}, widget: {...}} +} +``` + +**Если undefined** → интеграция не инициализировалась! + +--- + +## 2️⃣ Проверить виджет календаря + +```javascript +window.calendarWidget +``` + +**Должен вернуть объект FullCalendar** + +--- + +## 3️⃣ Проверить список календарей + +```javascript +// Если интеграция работает: +window.calendarIntegration.getCalendars() + +// Должно вернуть массив календарей: +// [{id: 1, title: "Personal", color: "#0d6efd", ...}, ...] +``` + +--- + +## 4️⃣ Проверить видимые календари + +```javascript +window.calendarIntegration.getVisibleCalendarIds() + +// Должно вернуть массив ID: [1, 2, 3] +``` + +--- + +## 5️⃣ Вручную загрузить события + +```javascript +// Попробовать загрузить события для видимых календарей +const start = new Date('2026-02-01'); +const end = new Date('2026-02-28'); + +window.calendarIntegration.fetchEventsForVisibleCalendars(start, end) + .then(events => { + console.log('✅ Events loaded:', events.length); + console.table(events); + }) + .catch(err => { + console.error('❌ Error:', err); + }); +``` + +--- + +## 6️⃣ Проверить, загружен ли скрипт интеграции + +```javascript +// Проверить, есть ли в DOM скрипт +document.querySelector('script[src*="calendarWidgetIntegration"]') + +// Должен вернуть + diff --git a/backend/test_calendar_frontend.html b/backend/test_calendar_frontend.html new file mode 100644 index 00000000..d57483ff --- /dev/null +++ b/backend/test_calendar_frontend.html @@ -0,0 +1,758 @@ + + + + + + Calendar Frontend Test + + + + + + + + +
+

🧪 Calendar Frontend Test Suite

+ + +
+
+

🎮 Test Controls

+
+ + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+

📊 Test Results

+
+ Ready +
+
+ +
+ + + + + + + + + + + + + + +
TestStatusDurationDetails
No tests run yet
+
+
+ + +
+
+

📅 Calendar UI Demo

+ +
+ +
+
+
My Calendars
+
+
+
+ Loading... +
+

Loading calendars...

+
+
+
+
+
+
+
+
+ + +
+
+

📝 Console Log

+ +
+
+
+
+ + + + + + + + + + + + diff --git a/backend/test_calendar_frontend_simple.html b/backend/test_calendar_frontend_simple.html new file mode 100644 index 00000000..3a8016fb --- /dev/null +++ b/backend/test_calendar_frontend_simple.html @@ -0,0 +1,720 @@ + + + + + + Calendar Frontend Test - Simple Version + + + + +
+

🧪 Calendar Frontend Test Suite (Offline Version)

+ + +
+
+

🎮 Test Controls

+
+ + +
+
+ +
+ + + + + + +
+
+ + +
+
+

📊 Test Results

+
+ Ready +
+
+ + + + + + + + + + + + + + + +
TestStatusDurationDetails
No tests run yet
+
+ + +
+
+

📅 Calendar List Demo

+ +
+ +
+
Loading calendars...
+
+
+ + +
+
+

📝 Console Log

+ +
+
+
+
+ + + +