Календарь: настройки первого дня и времени отображения, кружок сегодня

This commit is contained in:
dev
2026-11-28 13:09:40 +03:00
parent e5526617fe
commit c74042f297
10 changed files with 168 additions and 33 deletions
+23
View File
@@ -23,6 +23,9 @@ const CALENDAR_REMINDER_KEEP_DAYS = 7;
const CALENDAR_RANGE_MAX_DAYS = 62;
const CALENDAR_MAX_DURATION_MS = 31 * 24 * 60 * 60 * 1000;
const CALENDAR_SOURCES = ['groups', 'lesson_reports', 'digests'];
const CALENDAR_WEEK_START_DEFAULT = '1';
const CALENDAR_DAY_START_DEFAULT = '08:00';
const CALENDAR_DAY_END_DEFAULT = '21:00';
const CALENDAR_SOURCE_META = {
groups: { label: 'Занятия групп', color: 'green', link: 'groups.html' },
lesson_reports: { label: 'Отчёты о занятиях', color: 'purple', link: 'lessons.html' },
@@ -35,6 +38,20 @@ function calError(status, message) {
return err;
}
function normalizeCalendarWeekStart(value) {
return /^[0-6]$/.test(String(value ?? '')) ? String(value) : null;
}
function normalizeCalendarDayTime(value) {
return /^([01]\d|2[0-3]):[0-5]\d$/.test(String(value ?? '')) ? String(value) : null;
}
function calendarDayRange(start, end) {
const from = normalizeCalendarDayTime(start);
const to = normalizeCalendarDayTime(end);
return from && to && from < to ? { start: from, end: to } : null;
}
function parseUserId(value) {
if (typeof value !== 'number' && typeof value !== 'string') return NaN;
const s = String(value).trim();
@@ -647,11 +664,17 @@ module.exports = {
CALENDAR_NOTES_MAX,
CALENDAR_LOCATION_MAX,
CALENDAR_RANGE_MAX_DAYS,
CALENDAR_WEEK_START_DEFAULT,
CALENDAR_DAY_START_DEFAULT,
CALENDAR_DAY_END_DEFAULT,
ensureCalendarEventsTable,
listDueCalendarReminders,
sendDueCalendarReminders,
createCalendarReminderWorker,
normalizeCalendarRange,
normalizeCalendarWeekStart,
normalizeCalendarDayTime,
calendarDayRange,
validateCalendarEvent,
resolveCalendarUser,
calendarTarget,