Kalender-Sichtbarkeit persistent speichern + Sidebar-Overflow-Fix

- sidebar_hidden-Spalte zu calendars und google_calendars hinzugefügt
- Ausblenden-Button persistiert jetzt server-seitig (cross-device)
- Einblenden in Einstellungen schreibt sidebar_hidden=false zurück
- Sidebar: overflow-x hidden verhindert dass lange Namen den Button rausschieben
This commit is contained in:
2026-03-27 10:02:05 +01:00
parent f9f5d8c4cb
commit bad1ed500f
6 changed files with 35 additions and 12 deletions

View File

@@ -31,6 +31,18 @@ def _migrate():
logging.info("Migration: added week_start_day column")
except Exception:
pass # Column already exists
try:
conn.execute(text("ALTER TABLE calendars ADD COLUMN sidebar_hidden BOOLEAN DEFAULT 0"))
conn.commit()
logging.info("Migration: added sidebar_hidden to calendars")
except Exception:
pass
try:
conn.execute(text("ALTER TABLE google_calendars ADD COLUMN sidebar_hidden BOOLEAN DEFAULT 0"))
conn.commit()
logging.info("Migration: added sidebar_hidden to google_calendars")
except Exception:
pass
_migrate()

View File

@@ -59,6 +59,7 @@ class Calendar(Base):
name = Column(String(100), nullable=False)
color = Column(String(7), nullable=True)
enabled = Column(Boolean, default=True)
sidebar_hidden = Column(Boolean, default=False)
account = relationship("CalDAVAccount", back_populates="calendars")
@@ -168,5 +169,6 @@ class GoogleCalendar(Base):
name = Column(String(255), nullable=False)
color = Column(String(7), nullable=True)
enabled = Column(Boolean, default=True)
sidebar_hidden = Column(Boolean, default=False)
account = relationship("GoogleAccount", back_populates="calendars")

View File

@@ -29,6 +29,7 @@ class CalendarUpdate(BaseModel):
enabled: Optional[bool] = None
color: Optional[str] = None
name: Optional[str] = None
sidebar_hidden: Optional[bool] = None
class EventCreate(BaseModel):
@@ -67,6 +68,7 @@ def _account_dict(a: models.CalDAVAccount) -> dict:
"color": c.color or a.color,
"enabled": c.enabled,
"cal_id": c.cal_id,
"sidebar_hidden": bool(c.sidebar_hidden),
}
for c in a.calendars
],
@@ -225,6 +227,8 @@ def update_calendar(
calendar.color = data.color
if data.name is not None:
calendar.name = data.name
if data.sidebar_hidden is not None:
calendar.sidebar_hidden = data.sidebar_hidden
db.commit()
return {"ok": True}

View File

@@ -131,6 +131,7 @@ def _account_dict(a: models.GoogleAccount) -> dict:
"name": c.name,
"color": c.color or "#4285f4",
"enabled": c.enabled,
"sidebar_hidden": bool(c.sidebar_hidden),
}
for c in a.calendars
],
@@ -325,6 +326,7 @@ class GoogleCalendarUpdate(BaseModel):
enabled: Optional[bool] = None
color: Optional[str] = None
name: Optional[str] = None
sidebar_hidden: Optional[bool] = None
@router.put("/calendars/{calendar_id}")
@@ -351,6 +353,8 @@ def update_calendar(
gcal.color = data.color
if data.name is not None:
gcal.name = data.name
if data.sidebar_hidden is not None:
gcal.sidebar_hidden = data.sidebar_hidden
db.commit()
return {"ok": True}

View File

@@ -335,6 +335,7 @@ a { color: var(--primary); text-decoration: none; }
border-right: 1px solid var(--border);
flex-shrink: 0;
overflow-y: auto;
overflow-x: hidden;
transition: transform var(--transition);
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); margin-right: calc(-1 * var(--sidebar-w)); }

View File

@@ -262,7 +262,7 @@ function renderCalendarList() {
// ── CalDAV accounts ────────────────────────────────────
if (state.accounts.length) {
html += state.accounts.map(acc => {
const visibleCals = acc.calendars.filter(c => !c._hidden);
const visibleCals = acc.calendars.filter(c => !c.sidebar_hidden);
if (!visibleCals.length) return '';
return `<div class="cal-account-name">${escHtml(acc.name)}</div>` +
visibleCals.map(cal =>
@@ -311,7 +311,7 @@ function renderCalendarList() {
// ── Google accounts ───────────────────────────────────
if (state.googleAccounts.length) {
html += state.googleAccounts.map(acc => {
const visibleCals = acc.calendars.filter(c => !c._hidden);
const visibleCals = acc.calendars.filter(c => !c.sidebar_hidden);
if (!visibleCals.length) return `<div class="cal-account-name">${escHtml(acc.email)}</div>`;
return `<div class="cal-account-name">${escHtml(acc.email)}</div>` +
visibleCals.map(cal =>
@@ -467,10 +467,10 @@ function renderCalendarList() {
const source = btn.dataset.source;
if (source === 'caldav') {
const calId = parseInt(btn.dataset.calId);
await api.put(`/caldav/calendars/${calId}`, { enabled: false });
await api.put(`/caldav/calendars/${calId}`, { enabled: false, sidebar_hidden: true });
for (const acc of state.accounts) {
for (const cal of acc.calendars) {
if (cal.id === calId) { cal.enabled = false; cal._hidden = true; }
if (cal.id === calId) { cal.enabled = false; cal.sidebar_hidden = true; }
}
}
} else if (source === 'local') {
@@ -485,10 +485,10 @@ function renderCalendarList() {
state.icalSubscriptions = state.icalSubscriptions.filter(s => s.id !== subId);
} else if (source === 'google') {
const calId = parseInt(btn.dataset.calId);
await api.put(`/google/calendars/${calId}`, { enabled: false });
await api.put(`/google/calendars/${calId}`, { enabled: false, sidebar_hidden: true });
for (const acc of state.googleAccounts) {
for (const cal of acc.calendars) {
if (cal.id === calId) { cal.enabled = false; cal._hidden = true; }
if (cal.id === calId) { cal.enabled = false; cal.sidebar_hidden = true; }
}
}
}
@@ -1113,12 +1113,12 @@ function renderHiddenCalendars() {
const hidden = [];
for (const acc of state.accounts) {
for (const cal of acc.calendars) {
if (!cal.enabled || cal._hidden) hidden.push({ id: cal.id, name: cal.name, acc: acc.name, source: 'caldav' });
if (cal.sidebar_hidden) hidden.push({ id: cal.id, name: cal.name, acc: acc.name, source: 'caldav' });
}
}
for (const acc of state.googleAccounts) {
for (const cal of acc.calendars) {
if (!cal.enabled || cal._hidden) hidden.push({ id: cal.id, name: cal.name, acc: acc.email, source: 'google' });
if (cal.sidebar_hidden) hidden.push({ id: cal.id, name: cal.name, acc: acc.email, source: 'google' });
}
}
if (!hidden.length) {
@@ -1136,17 +1136,17 @@ function renderHiddenCalendars() {
const calId = parseInt(btn.dataset.restoreCal);
const source = btn.dataset.restoreSource;
if (source === 'google') {
await api.put(`/google/calendars/${calId}`, { enabled: true });
await api.put(`/google/calendars/${calId}`, { enabled: true, sidebar_hidden: false });
for (const acc of state.googleAccounts) {
for (const cal of acc.calendars) {
if (cal.id === calId) { cal.enabled = true; delete cal._hidden; }
if (cal.id === calId) { cal.enabled = true; cal.sidebar_hidden = false; }
}
}
} else {
await api.put(`/caldav/calendars/${calId}`, { enabled: true });
await api.put(`/caldav/calendars/${calId}`, { enabled: true, sidebar_hidden: false });
for (const acc of state.accounts) {
for (const cal of acc.calendars) {
if (cal.id === calId) { cal.enabled = true; delete cal._hidden; }
if (cal.id === calId) { cal.enabled = true; cal.sidebar_hidden = false; }
}
}
}