Добавить общие события и множественный выбор в календарь
This commit is contained in:
+193
-24
@@ -23,6 +23,7 @@
|
||||
const state = {
|
||||
view: 'week', anchorIso: '', items: [], sources: [], hidden: new Set(),
|
||||
rangeFrom: '', rangeTo: '', grid: null, uidMap: new Map(), editor: null,
|
||||
users: [], ownerFilter: '',
|
||||
};
|
||||
let nowTimer = null;
|
||||
let drag = null;
|
||||
@@ -49,6 +50,7 @@
|
||||
localStorage.setItem('calView', state.view);
|
||||
localStorage.setItem('calAnchor', state.anchorIso);
|
||||
localStorage.setItem('calSources', JSON.stringify([...state.hidden]));
|
||||
localStorage.setItem('calOwner', state.ownerFilter);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -60,6 +62,7 @@
|
||||
view = localStorage.getItem('calView') || '';
|
||||
anchor = localStorage.getItem('calAnchor') || '';
|
||||
hidden = JSON.parse(localStorage.getItem('calSources') || '[]');
|
||||
state.ownerFilter = isAdmin() ? (localStorage.getItem('calOwner') || '') : '';
|
||||
} catch {}
|
||||
if (VIEWS.includes(view)) state.view = view;
|
||||
if (dtIsoMatch(anchor)) state.anchorIso = anchor;
|
||||
@@ -67,6 +70,37 @@
|
||||
if (!state.anchorIso) state.anchorIso = todayIso();
|
||||
}
|
||||
|
||||
function userLabel(u) {
|
||||
return u.name || u.username || `#${u.id}`;
|
||||
}
|
||||
|
||||
function userOption(u) {
|
||||
return `<option value="${u.id}">${esc(userLabel(u))}${u.role === 'admin' ? ' (админ)' : ''}</option>`;
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
if (!isAdmin()) return;
|
||||
try {
|
||||
const data = await request('/api/calendar/users');
|
||||
state.users = Array.isArray(data.items) ? data.items : [];
|
||||
} catch (e) {
|
||||
console.error('calendar users:', e);
|
||||
state.users = [];
|
||||
}
|
||||
}
|
||||
|
||||
function renderUserFilter() {
|
||||
const sel = document.getElementById('calUserFilter');
|
||||
sel.classList.toggle('cal-hidden', !isAdmin());
|
||||
if (!isAdmin()) return;
|
||||
sel.innerHTML = '<option value="">Все пользователи</option>' + state.users.map(userOption).join('');
|
||||
sel.value = state.ownerFilter;
|
||||
if (sel.value !== state.ownerFilter) {
|
||||
state.ownerFilter = sel.value;
|
||||
saveState();
|
||||
}
|
||||
}
|
||||
|
||||
function weekBounds(iso) {
|
||||
const dow = isoDow(iso);
|
||||
if (dow < 0) return { from: iso, to: iso };
|
||||
@@ -155,6 +189,10 @@
|
||||
allDay: it.all_day === true, color: it.color,
|
||||
notes: it.notes || '', location: it.location || '', repeat: it.repeat_rule || 'none',
|
||||
repeatUntil: it.repeat_until, reminders: it.reminder_minutes || [],
|
||||
ownerId: it.user_id || null, ownerName: it.user_name || '',
|
||||
isCommon: it.is_common === true,
|
||||
readOnly: it.is_common === true && !isAdmin(),
|
||||
assigned: isAdmin() && it.is_common !== true && Number(it.user_id) !== Number(currentUser.id),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -255,6 +293,15 @@
|
||||
return meta ? `<i data-lucide="${meta.icon}"></i>` : '';
|
||||
}
|
||||
|
||||
function eventOwnerLabel(seg) {
|
||||
if (seg.isCommon) return '<span class="cal-owner">Общее: </span>';
|
||||
return seg.assigned && seg.ownerName ? `<span class="cal-owner">${esc(seg.ownerName)}: </span>` : '';
|
||||
}
|
||||
|
||||
function eventClass(base, seg) {
|
||||
return `${base}${seg.isCommon ? ' is-common' : ''}${seg.assigned ? ' is-assigned' : ''}`;
|
||||
}
|
||||
|
||||
function segmentHtml(seg, hours) {
|
||||
const top = (seg.startMin - hours.start * 60) / 60 * HOUR_H;
|
||||
const height = Math.max(20, (seg.endMin - seg.startMin) / 60 * HOUR_H - 2);
|
||||
@@ -263,14 +310,16 @@
|
||||
const style = `--ev:${colorHex(seg.color)};top:${Math.round(top)}px;height:${Math.round(height)}px;left:${left.toFixed(3)}%;width:${(width - 0.4).toFixed(3)}%`;
|
||||
const time = height >= 34 ? `<span class="cal-event-time">${esc(fmtHmStr(hmFromMinutes(seg.startMin)))}</span>` : '';
|
||||
const mark = seg.continued ? '↔ ' : '';
|
||||
const owner = eventOwnerLabel(seg);
|
||||
const title = `${mark}${esc(seg.title)}`;
|
||||
const cls = seg.source === 'personal' ? 'cal-event' : 'cal-event is-source';
|
||||
return `<div class="${cls}" style="${style}" data-ev="${attrEsc(seg.uid)}" title="${attrEsc(seg.title)}">${sourceIcon(seg)}${time}${title}</div>`;
|
||||
const cls = seg.source === 'personal' ? eventClass('cal-event', seg) : 'cal-event is-source';
|
||||
return `<div class="${cls}" style="${style}" data-ev="${attrEsc(seg.uid)}" title="${attrEsc(seg.title)}">${sourceIcon(seg)}${time}${owner}${title}</div>`;
|
||||
}
|
||||
|
||||
function allDayHtml(seg) {
|
||||
const cls = seg.source === 'personal' ? 'cal-allday-chip' : 'cal-allday-chip is-source';
|
||||
return `<div class="${cls}" style="--ev:${colorHex(seg.color)}" data-ev="${attrEsc(seg.uid)}" title="${attrEsc(seg.title)}">${esc(seg.title)}</div>`;
|
||||
const cls = seg.source === 'personal' ? eventClass('cal-allday-chip', seg) : 'cal-allday-chip is-source';
|
||||
const owner = eventOwnerLabel(seg);
|
||||
return `<div class="${cls}" style="--ev:${colorHex(seg.color)}" data-ev="${attrEsc(seg.uid)}" title="${attrEsc(seg.title)}">${owner}${esc(seg.title)}</div>`;
|
||||
}
|
||||
|
||||
function nowTop(hours) {
|
||||
@@ -345,8 +394,9 @@
|
||||
html += `<span class="cal-month-num" data-open-day="${iso}">${iso === bounds.from ? `${Number(iso.slice(8, 10))} ${esc(fmtMonthYearIso(iso).split(' ')[0])}` : Number(iso.slice(8, 10))}</span>`;
|
||||
segs.slice(0, 3).forEach(seg => {
|
||||
const time = seg.allDay ? '' : `${esc(fmtHmStr(hmFromMinutes(seg.startMin)))} `;
|
||||
const cls = seg.source === 'personal' ? 'cal-month-chip' : 'cal-month-chip is-source';
|
||||
html += `<div class="${cls}" style="--ev:${colorHex(seg.color)}" data-ev="${attrEsc(seg.uid)}" title="${attrEsc(seg.title)}">${time}${esc(seg.title)}</div>`;
|
||||
const cls = seg.source === 'personal' ? eventClass('cal-month-chip', seg) : 'cal-month-chip is-source';
|
||||
const owner = eventOwnerLabel(seg);
|
||||
html += `<div class="${cls}" style="--ev:${colorHex(seg.color)}" data-ev="${attrEsc(seg.uid)}" title="${attrEsc(seg.title)}">${time}${owner}${esc(seg.title)}</div>`;
|
||||
});
|
||||
if (segs.length > 3) html += `<div class="cal-more">+ ещё ${segs.length - 3}</div>`;
|
||||
html += '</div>';
|
||||
@@ -376,7 +426,7 @@
|
||||
html += `<div class="cal-agenda-day"><div class="cal-agenda-date">${esc(fmtDateOnlyLongIso(day))}</div>`;
|
||||
segs.forEach(seg => {
|
||||
const time = seg.allDay ? 'Весь день' : `${fmtHmStr(hmFromMinutes(seg.startMin))} – ${fmtHmStr(hmFromMinutes(seg.endMin))}`;
|
||||
const meta = [seg.location, seg.notes, seg.source !== 'personal' ? REPEAT_LABELS[seg.repeat] || '' : ''].filter(Boolean).join(' · ');
|
||||
const meta = [seg.isCommon ? 'Общее событие' : (seg.assigned ? seg.ownerName : ''), seg.location, seg.notes, seg.source !== 'personal' ? REPEAT_LABELS[seg.repeat] || '' : ''].filter(Boolean).join(' · ');
|
||||
html += `<div class="cal-agenda-row" data-ev="${attrEsc(seg.uid)}"><span class="cal-agenda-time">${esc(time)}</span><span class="cal-dot" style="--ev:${colorHex(seg.color)}"></span><div class="cal-agenda-body"><div class="cal-agenda-title">${esc(seg.title)}</div>${meta ? `<div class="cal-agenda-meta">${esc(meta)}</div>` : ''}</div></div>`;
|
||||
});
|
||||
html += '</div>';
|
||||
@@ -430,8 +480,9 @@
|
||||
}
|
||||
|
||||
function renderSide() {
|
||||
const personalLabel = isAdmin() && !state.ownerFilter ? 'Все события' : 'Личный';
|
||||
document.getElementById('calCalendars').innerHTML =
|
||||
`<label class="cal-personal-row" style="--ev:${COLOR_HEX.blue}"><input type="checkbox" data-hidden="personal" ${state.hidden.has('personal') ? '' : 'checked'}><span class="cal-dot"></span><span class="cal-source-label">Личный</span></label>`;
|
||||
`<label class="cal-personal-row" style="--ev:${COLOR_HEX.blue}"><input type="checkbox" data-hidden="personal" ${state.hidden.has('personal') ? '' : 'checked'}><span class="cal-dot"></span><span class="cal-source-label">${personalLabel}</span></label>`;
|
||||
document.getElementById('calSources').innerHTML = state.sources.map(src => {
|
||||
const meta = SOURCE_META[src.id] || {};
|
||||
return `<label class="cal-source-row" style="--ev:${colorHex(src.color)}"><input type="checkbox" data-hidden="${attrEsc(src.id)}" ${state.hidden.has(src.id) ? '' : 'checked'}><span class="cal-dot"></span>${meta.icon ? `<i data-lucide="${meta.icon}"></i>` : ''}<span class="cal-source-label">${esc(meta.label || src.label || src.id)}</span><span class="cal-source-count">${(src.items || []).length}</span></label>`;
|
||||
@@ -547,10 +598,41 @@
|
||||
|
||||
function renderColors() {
|
||||
document.getElementById('calColors').innerHTML = COLORS.map(name =>
|
||||
`<button class="cal-color${name === state.editor.color ? ' on' : ''}" type="button" data-color="${name}" style="--ev:${COLOR_HEX[name]}" aria-label="${name}"></button>`
|
||||
`<button class="cal-color${name === state.editor.color ? ' on' : ''}" type="button" data-color="${name}" style="--ev:${COLOR_HEX[name]}" aria-label="${name}"${state.editor.readOnly ? ' disabled' : ''}></button>`
|
||||
).join('');
|
||||
}
|
||||
|
||||
function updateAssigneeHint() {
|
||||
if (!state.editor || !isAdmin()) return;
|
||||
const hint = document.getElementById('calAssigneeHint');
|
||||
if (state.editor.isCommon) hint.textContent = 'Видно всем пользователям, включая новых';
|
||||
else if (state.editor.id) hint.textContent = 'При редактировании можно выбрать одного пользователя';
|
||||
else {
|
||||
const count = state.editor.selectedUserIds.length;
|
||||
hint.textContent = count ? `Выбрано пользователей: ${count}` : 'Выберите хотя бы одного пользователя';
|
||||
}
|
||||
}
|
||||
|
||||
function renderAssignee() {
|
||||
const row = document.getElementById('calAssigneeRow');
|
||||
row.classList.toggle('cal-hidden', !isAdmin());
|
||||
if (!isAdmin() || !state.editor) return;
|
||||
const editor = state.editor;
|
||||
const selected = new Set(editor.selectedUserIds.map(Number));
|
||||
const known = new Set(state.users.map(u => Number(u.id)));
|
||||
document.getElementById('calAssigneeCommon').checked = editor.isCommon;
|
||||
document.getElementById('calAssigneeBox').classList.toggle('is-common', editor.isCommon);
|
||||
document.getElementById('calAssigneeList').innerHTML =
|
||||
state.users.map(u => {
|
||||
const id = Number(u.id);
|
||||
return `<label><input type="checkbox" data-user="${id}"${selected.has(id) ? ' checked' : ''}><span>${esc(userLabel(u))}${u.role === 'admin' ? ' (админ)' : ''}</span></label>`;
|
||||
}).join('') +
|
||||
[...selected].filter(id => !known.has(id)).map(id =>
|
||||
`<label title="Пользователь недоступен"><input type="checkbox" checked disabled><span>#${id} (недоступен)</span></label>`
|
||||
).join('');
|
||||
updateAssigneeHint();
|
||||
}
|
||||
|
||||
function reminderLabel(n) {
|
||||
if (n === 0) return 'в момент события';
|
||||
if (n === 1440) return 'за 1 день';
|
||||
@@ -561,7 +643,7 @@
|
||||
|
||||
function renderReminders() {
|
||||
document.getElementById('calReminders').innerHTML = state.editor.reminders.map(n =>
|
||||
`<span class="cal-rem-chip" data-rem="${n}" role="button" tabindex="0">${reminderLabel(n)} ×</span>`
|
||||
`<span class="cal-rem-chip" data-rem="${n}" role="button" tabindex="0">${reminderLabel(n)}${state.editor.readOnly ? '' : ' ×'}</span>`
|
||||
).join('');
|
||||
}
|
||||
|
||||
@@ -571,14 +653,39 @@
|
||||
document.getElementById('calRepeatUntilRow').classList.toggle('cal-hidden', document.getElementById('calRepeat').value === 'none');
|
||||
}
|
||||
|
||||
function setEditorReadOnly(readOnly) {
|
||||
const ids = ['calTitle', 'calStartDate', 'calStartTime', 'calEndDate', 'calEndTime', 'calAllDay',
|
||||
'calRepeat', 'calRepeatUntil', 'calLocation', 'calNotes', 'calReminderAdd', 'calReminderAddBtn'];
|
||||
ids.forEach(id => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) el.disabled = readOnly;
|
||||
});
|
||||
document.getElementById('calSaveBtn').classList.toggle('cal-hidden', readOnly);
|
||||
document.getElementById('calDeleteBtn').classList.add('cal-hidden');
|
||||
if (!readOnly) document.getElementById('calDeleteBtn').classList.toggle('cal-hidden', !state.editor || !state.editor.id);
|
||||
}
|
||||
|
||||
function openEditor(prefill) {
|
||||
const p = prefill || {};
|
||||
const admin = isAdmin();
|
||||
const ownerId = p.ownerId ? Number(p.ownerId) : (currentUser ? Number(currentUser.id) : null);
|
||||
const selectedUserIds = Array.isArray(p.selectedUserIds)
|
||||
? [...new Set(p.selectedUserIds.map(Number))]
|
||||
: (admin && ownerId ? [ownerId] : []);
|
||||
state.editor = {
|
||||
id: p.id || null,
|
||||
ownerId,
|
||||
isCommon: p.isCommon === true,
|
||||
readOnly: p.readOnly === true,
|
||||
selectedUserIds,
|
||||
originalUserIds: [...selectedUserIds],
|
||||
color: COLORS.includes(p.color) ? p.color : 'blue',
|
||||
reminders: Array.isArray(p.reminders) ? [...p.reminders].sort((a, b) => a - b) : [],
|
||||
};
|
||||
document.getElementById('calModalTitle').textContent = p.id ? 'Событие' : 'Новое событие';
|
||||
const title = state.editor.isCommon || state.editor.readOnly
|
||||
? 'Общее событие'
|
||||
: (p.id ? 'Событие' : 'Новое событие');
|
||||
document.getElementById('calModalTitle').textContent = title;
|
||||
document.getElementById('calTitle').value = p.title || '';
|
||||
document.getElementById('calStartDate').value = p.dateStart || state.anchorIso;
|
||||
document.getElementById('calStartTime').value = p.timeStart || '10:00';
|
||||
@@ -589,13 +696,14 @@
|
||||
document.getElementById('calRepeatUntil').value = p.repeatUntil || '';
|
||||
document.getElementById('calLocation').value = p.location || '';
|
||||
document.getElementById('calNotes').value = p.notes || '';
|
||||
document.getElementById('calDeleteBtn').classList.toggle('cal-hidden', !p.id);
|
||||
setEditorReadOnly(state.editor.readOnly);
|
||||
renderAssignee();
|
||||
renderColors();
|
||||
renderReminders();
|
||||
syncAllDay();
|
||||
document.getElementById('calEventModal').classList.add('open');
|
||||
renderIcons();
|
||||
document.getElementById('calTitle').focus();
|
||||
(state.editor.readOnly ? document.getElementById('calCancelBtn') : document.getElementById('calTitle')).focus();
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
@@ -618,6 +726,7 @@
|
||||
: dtToLocalInput(item.id && seriesEnd ? seriesEnd : new Date(item.end).toISOString());
|
||||
openEditor({
|
||||
id: item.id, title: item.title, color: item.color, notes: item.notes,
|
||||
ownerId: item.ownerId, isCommon: item.isCommon, readOnly: item.readOnly,
|
||||
location: item.location, repeat: item.repeat, repeatUntil: item.repeatUntil,
|
||||
reminders: item.reminders, allDay: item.allDay,
|
||||
dateStart: startLocal.slice(0, 10), timeStart: startLocal.slice(11, 16),
|
||||
@@ -626,7 +735,8 @@
|
||||
}
|
||||
|
||||
async function saveEditor() {
|
||||
if (!state.editor) return;
|
||||
if (!state.editor || state.editor.readOnly) return;
|
||||
const editor = state.editor;
|
||||
const title = document.getElementById('calTitle').value.trim();
|
||||
if (!title) { showToast('Укажите заголовок события', true); return; }
|
||||
const allDay = document.getElementById('calAllDay').checked;
|
||||
@@ -649,23 +759,49 @@
|
||||
showToast('Повторяющееся событие не может длиться больше 7 дней', true);
|
||||
return;
|
||||
}
|
||||
if (state.editor.reminders.length > 5) { showToast('Не больше 5 напоминаний', true); return; }
|
||||
if (editor.reminders.length > 5) { showToast('Не больше 5 напоминаний', true); return; }
|
||||
const repeatUntil = repeat !== 'none' ? document.getElementById('calRepeatUntil').value : '';
|
||||
if (repeatUntil && repeatUntil < startDate) { showToast('Повтор должен заканчиваться не раньше начала', true); return; }
|
||||
const body = {
|
||||
title, notes: document.getElementById('calNotes').value,
|
||||
location: document.getElementById('calLocation').value,
|
||||
color: state.editor.color, all_day: allDay, starts_at: startsAt, ends_at: endsAt,
|
||||
color: editor.color, all_day: allDay, starts_at: startsAt, ends_at: endsAt,
|
||||
repeat_rule: repeat, repeat_until: repeatUntil || null,
|
||||
reminder_minutes: state.editor.reminders,
|
||||
reminder_minutes: editor.reminders,
|
||||
};
|
||||
const id = state.editor.id;
|
||||
if (isAdmin()) {
|
||||
if (editor.isCommon) {
|
||||
body.is_common = true;
|
||||
} else {
|
||||
const selected = [...new Set(editor.selectedUserIds.map(Number))].filter(n => Number.isInteger(n) && n > 0);
|
||||
if (!selected.length) { showToast('Выберите пользователя', true); return; }
|
||||
const unavailable = selected.filter(id => !state.users.some(u => Number(u.id) === id));
|
||||
const unchanged = editor.id && selected.length === editor.originalUserIds.length &&
|
||||
selected.every(id => editor.originalUserIds.includes(id));
|
||||
if (unavailable.length) {
|
||||
if (!(unavailable.length === selected.length && unchanged)) {
|
||||
showToast('Выбранный пользователь недоступен', true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
body.user_ids = selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
const id = editor.id;
|
||||
try {
|
||||
await request(id ? `/api/calendar/events/${id}` : '/api/calendar/events', {
|
||||
const result = await request(id ? `/api/calendar/events/${id}` : '/api/calendar/events', {
|
||||
method: id ? 'PUT' : 'POST', body,
|
||||
});
|
||||
const count = id ? 1 : (Array.isArray(result.items) ? result.items.length : 1);
|
||||
closeEditor();
|
||||
showToast('Событие сохранено');
|
||||
showToast(count > 1 ? `События сохранены: ${count}` : 'Событие сохранено');
|
||||
if (!id && !editor.isCommon && state.ownerFilter &&
|
||||
!editor.selectedUserIds.some(uid => String(uid) === state.ownerFilter)) {
|
||||
state.ownerFilter = '';
|
||||
saveState();
|
||||
renderUserFilter();
|
||||
}
|
||||
await reload();
|
||||
} catch (e) {
|
||||
showToast(e.message, true);
|
||||
@@ -673,7 +809,7 @@
|
||||
}
|
||||
|
||||
async function removeEditor() {
|
||||
if (!state.editor || !state.editor.id || !confirm('Удалить событие?')) return;
|
||||
if (!state.editor || state.editor.readOnly || !state.editor.id || !confirm('Удалить событие?')) return;
|
||||
try {
|
||||
await request(`/api/calendar/events/${state.editor.id}`, { method: 'DELETE' });
|
||||
closeEditor();
|
||||
@@ -686,7 +822,9 @@
|
||||
|
||||
async function loadRange() {
|
||||
const w = queryWindow();
|
||||
const data = await request(`/api/calendar/events?from=${encodeURIComponent(w.from)}&to=${encodeURIComponent(w.to)}`);
|
||||
let path = `/api/calendar/events?from=${encodeURIComponent(w.from)}&to=${encodeURIComponent(w.to)}`;
|
||||
if (isAdmin() && state.ownerFilter) path += `&user_id=${encodeURIComponent(state.ownerFilter)}`;
|
||||
const data = await request(path);
|
||||
return { from: w.from, to: w.to, data };
|
||||
}
|
||||
|
||||
@@ -734,6 +872,34 @@
|
||||
const btn = e.target.closest('[data-view]');
|
||||
if (btn) setView(btn.dataset.view);
|
||||
});
|
||||
document.getElementById('calUserFilter').addEventListener('change', e => {
|
||||
state.ownerFilter = e.target.value;
|
||||
saveState();
|
||||
reload();
|
||||
});
|
||||
document.getElementById('calAssigneeCommon').addEventListener('change', e => {
|
||||
if (!state.editor) return;
|
||||
state.editor.isCommon = e.target.checked;
|
||||
renderAssignee();
|
||||
});
|
||||
document.getElementById('calAssigneeAllBtn').addEventListener('click', () => {
|
||||
if (!state.editor || state.editor.isCommon) return;
|
||||
state.editor.selectedUserIds = state.users.map(u => Number(u.id));
|
||||
renderAssignee();
|
||||
});
|
||||
document.getElementById('calAssigneeList').addEventListener('change', e => {
|
||||
const input = e.target.closest('input[data-user]');
|
||||
if (!input || input.disabled || !state.editor || state.editor.isCommon) return;
|
||||
const uid = Number(input.dataset.user);
|
||||
if (state.editor.id) {
|
||||
state.editor.selectedUserIds = input.checked ? [uid] : [];
|
||||
} else if (input.checked) {
|
||||
if (!state.editor.selectedUserIds.includes(uid)) state.editor.selectedUserIds.push(uid);
|
||||
} else {
|
||||
state.editor.selectedUserIds = state.editor.selectedUserIds.filter(id => id !== uid);
|
||||
}
|
||||
renderAssignee();
|
||||
});
|
||||
document.getElementById('calNewBtn').addEventListener('click', () => openEditor({
|
||||
dateStart: state.anchorIso, timeStart: '10:00', dateEnd: state.anchorIso, timeEnd: '11:00',
|
||||
}));
|
||||
@@ -791,17 +957,18 @@
|
||||
document.getElementById('calRepeat').addEventListener('change', syncAllDay);
|
||||
document.getElementById('calColors').addEventListener('click', e => {
|
||||
const btn = e.target.closest('[data-color]');
|
||||
if (!btn) return;
|
||||
if (!btn || !state.editor || state.editor.readOnly) return;
|
||||
state.editor.color = btn.dataset.color;
|
||||
renderColors();
|
||||
});
|
||||
document.getElementById('calReminders').addEventListener('click', e => {
|
||||
const chip = e.target.closest('[data-rem]');
|
||||
if (!chip) return;
|
||||
if (!chip || !state.editor || state.editor.readOnly) return;
|
||||
state.editor.reminders = state.editor.reminders.filter(n => n !== Number(chip.dataset.rem));
|
||||
renderReminders();
|
||||
});
|
||||
document.getElementById('calReminderAddBtn').addEventListener('click', () => {
|
||||
if (!state.editor || state.editor.readOnly) return;
|
||||
const n = Number(document.getElementById('calReminderAdd').value);
|
||||
if (state.editor.reminders.length >= 5) { showToast('Не больше 5 напоминаний', true); return; }
|
||||
if (!state.editor.reminders.includes(n)) state.editor.reminders.push(n);
|
||||
@@ -830,8 +997,10 @@
|
||||
async function init() {
|
||||
if (!(await checkAuth())) return;
|
||||
loadState();
|
||||
await loadUsers();
|
||||
buildSidebar(document.body.dataset.page);
|
||||
bindUi();
|
||||
renderUserFilter();
|
||||
render();
|
||||
await reload();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user