From bad1ed500f7161d81d6226d22653b916c290a428 Mon Sep 17 00:00:00 2001 From: Scarriffle Date: Fri, 27 Mar 2026 10:02:05 +0100 Subject: [PATCH] =?UTF-8?q?Kalender-Sichtbarkeit=20persistent=20speichern?= =?UTF-8?q?=20+=20Sidebar-Overflow-Fix=20-=20sidebar=5Fhidden-Spalte=20zu?= =?UTF-8?q?=20calendars=20und=20google=5Fcalendars=20hinzugef=C3=BCgt=20-?= =?UTF-8?q?=20Ausblenden-Button=20persistiert=20jetzt=20server-seitig=20(c?= =?UTF-8?q?ross-device)=20-=20Einblenden=20in=20Einstellungen=20schreibt?= =?UTF-8?q?=20sidebar=5Fhidden=3Dfalse=20zur=C3=BCck=20-=20Sidebar:=20over?= =?UTF-8?q?flow-x=20hidden=20verhindert=20dass=20lange=20Namen=20den=20But?= =?UTF-8?q?ton=20rausschieben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 12 ++++++++++++ backend/models.py | 2 ++ backend/routers/caldav_router.py | 4 ++++ backend/routers/google_router.py | 4 ++++ frontend/css/app.css | 1 + frontend/js/calendar.js | 24 ++++++++++++------------ 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/backend/main.py b/backend/main.py index 8834467..9cc9988 100644 --- a/backend/main.py +++ b/backend/main.py @@ -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() diff --git a/backend/models.py b/backend/models.py index 55920db..eef1bc3 100644 --- a/backend/models.py +++ b/backend/models.py @@ -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") diff --git a/backend/routers/caldav_router.py b/backend/routers/caldav_router.py index 67b851b..a0d61aa 100644 --- a/backend/routers/caldav_router.py +++ b/backend/routers/caldav_router.py @@ -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} diff --git a/backend/routers/google_router.py b/backend/routers/google_router.py index e2a7e03..a944a05 100644 --- a/backend/routers/google_router.py +++ b/backend/routers/google_router.py @@ -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} diff --git a/frontend/css/app.css b/frontend/css/app.css index 0d541f8..0e1cbbb 100644 --- a/frontend/css/app.css +++ b/frontend/css/app.css @@ -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)); } diff --git a/frontend/js/calendar.js b/frontend/js/calendar.js index ac402e2..49cfadd 100644 --- a/frontend/js/calendar.js +++ b/frontend/js/calendar.js @@ -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 `
${escHtml(acc.name)}
` + 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 `
${escHtml(acc.email)}
`; return `
${escHtml(acc.email)}
` + 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; } } } }