fix: Termine in unchecked Kalendern erstellen + HA-Kalender als Kopier-Ziel

- populateCalendarSelect: filtert jetzt nach !sidebar_hidden statt
  enabled. Unchecked (versteckte) Kalender bleiben so im
  Termin-erstellen-Dropdown verfügbar
- buildWritableCalendars: HA-Kalender werden als Kopier-Ziele aufgeführt
- copyEventToCalendar: routet HA-Ziele über /homeassistant/events
  Endpoint (vorher fielen sie in den CalDAV-Fallback)
This commit is contained in:
Scarriffle
2026-05-05 17:46:12 +02:00
parent 0e6672b909
commit ac5996693f

View File

@@ -1071,9 +1071,9 @@ document.addEventListener('click', e => {
function populateCalendarSelect(selectedId) { function populateCalendarSelect(selectedId) {
const sel = document.getElementById('ev-calendar'); const sel = document.getElementById('ev-calendar');
sel.innerHTML = ''; sel.innerHTML = '';
// CalDAV calendars // CalDAV calendars (show all that aren't removed from sidebar, even if unchecked)
state.accounts.forEach(acc => { state.accounts.forEach(acc => {
acc.calendars.filter(c => c.enabled).forEach(cal => { acc.calendars.filter(c => !c.sidebar_hidden).forEach(cal => {
const opt = document.createElement('option'); const opt = document.createElement('option');
opt.value = cal.id; opt.value = cal.id;
opt.textContent = `${acc.name} / ${cal.name}`; opt.textContent = `${acc.name} / ${cal.name}`;
@@ -1082,7 +1082,7 @@ function populateCalendarSelect(selectedId) {
}); });
}); });
// Local calendars // Local calendars
state.localCalendars.filter(c => c.enabled).forEach(cal => { state.localCalendars.filter(c => !c.sidebar_hidden).forEach(cal => {
const opt = document.createElement('option'); const opt = document.createElement('option');
opt.value = `local-${cal.id}`; opt.value = `local-${cal.id}`;
opt.textContent = cal.name; opt.textContent = cal.name;
@@ -1092,7 +1092,7 @@ function populateCalendarSelect(selectedId) {
// iCal subscriptions are read-only, not shown here // iCal subscriptions are read-only, not shown here
// Google calendars (read/write) // Google calendars (read/write)
state.googleAccounts.forEach(acc => { state.googleAccounts.forEach(acc => {
acc.calendars.filter(c => c.enabled).forEach(cal => { acc.calendars.filter(c => !c.sidebar_hidden).forEach(cal => {
const opt = document.createElement('option'); const opt = document.createElement('option');
opt.value = `google-${cal.id}`; opt.value = `google-${cal.id}`;
opt.textContent = `${acc.email} / ${cal.name}`; opt.textContent = `${acc.email} / ${cal.name}`;
@@ -1102,7 +1102,7 @@ function populateCalendarSelect(selectedId) {
}); });
// Home Assistant calendars // Home Assistant calendars
state.haAccounts.forEach(acc => { state.haAccounts.forEach(acc => {
acc.calendars.filter(c => c.enabled).forEach(cal => { acc.calendars.filter(c => !c.sidebar_hidden).forEach(cal => {
const opt = document.createElement('option'); const opt = document.createElement('option');
opt.value = `homeassistant-${cal.id}`; opt.value = `homeassistant-${cal.id}`;
opt.textContent = `${acc.name} / ${cal.name}`; opt.textContent = `${acc.name} / ${cal.name}`;
@@ -2512,6 +2512,7 @@ function buildWritableCalendars(_excludeEv) {
} }
} }
for (const cal of state.localCalendars) { for (const cal of state.localCalendars) {
if (cal.sidebar_hidden) continue;
list.push({ _idx: idx++, id: cal.id, name: cal.name, color: cal.color || '#34a853', type: 'local' }); list.push({ _idx: idx++, id: cal.id, name: cal.name, color: cal.color || '#34a853', type: 'local' });
} }
for (const acc of state.googleAccounts) { for (const acc of state.googleAccounts) {
@@ -2520,6 +2521,12 @@ function buildWritableCalendars(_excludeEv) {
list.push({ _idx: idx++, id: cal.id, name: `${acc.email} / ${cal.name}`, color: cal.color || '#4285f4', type: 'google' }); list.push({ _idx: idx++, id: cal.id, name: `${acc.email} / ${cal.name}`, color: cal.color || '#4285f4', type: 'google' });
} }
} }
for (const acc of state.haAccounts) {
for (const cal of acc.calendars) {
if (cal.sidebar_hidden) continue;
list.push({ _idx: idx++, id: cal.id, name: `${acc.name} / ${cal.name}`, color: cal.color || '#03a9f4', type: 'homeassistant' });
}
}
return list; return list;
} }
@@ -2540,6 +2547,11 @@ async function copyEventToCalendar(ev, cal) {
calendar_id: cal.id, title, start, end, allDay, calendar_id: cal.id, title, start, end, allDay,
location: location || '', description: description || '', color: color || null, location: location || '', description: description || '', color: color || null,
}); });
} else if (cal.type === 'homeassistant') {
await api.post('/homeassistant/events', {
calendar_id: cal.id, title, start, end, allDay,
location: location || '', description: description || '',
});
} else { } else {
await api.post('/caldav/events', { await api.post('/caldav/events', {
calendar_id: cal.id, title, start, end, allDay, calendar_id: cal.id, title, start, end, allDay,