Adds TaskWidgetConfig.name (migration 19, plain column add) shown at the top of the widget on the actual panel instead of the hardcoded "Tasks" header -- e.g. "Chores" or "Mom's list". The only widget type with its own on-panel title at all, since it's the only one where "which list is this" isn't already obvious from a calendar/photo/ whiteboard's own content. Threaded through calendar_render's _draw_tasks/_build_tasks/ render_tasks/render_tasks_preview_png as a `title` param (default "Tasks", truncated to fit -- a long custom name shouldn't be able to overflow the widget's box), the config-save endpoint (tasks_name, truncated server-side to a sane header length rather than rejected), and a new "Settings" section in the tasks dialog. Verified live in the browser: the name actually renders at the top of the real composited panel (not just the dialog preview, which stays gated on having a configured source), and persists correctly on both desktop and mobile. Full suite (196 tests) passes.
43 lines
1.9 KiB
Python
43 lines
1.9 KiB
Python
"""Tasks widget: a simple outstanding-task checklist merged from one or
|
|
more of its linked users' CalDAV task lists, in its own region -- split
|
|
out of the calendar widget's old week-view-only, single-list task list
|
|
(see models.TaskWidgetConfig) so a task list can be placed and sized on
|
|
its own, independent of any calendar's view/footprint, and can merge
|
|
more than one person's list the same way a calendar widget merges more
|
|
than one person's calendar (see models.FrameTaskList).
|
|
|
|
No "enabled" concept and no button actions: the widget's mere presence
|
|
on the grid is the on/off switch (same as every other widget type), and
|
|
its cache refreshes on the same throttled schedule as weather -- nothing
|
|
here to advance/back/force. No placeholder for "nothing included yet"
|
|
either -- same posture as app/widgets/calendar.py, which this otherwise
|
|
mirrors closely: render() always draws through get_or_refresh_tasks_
|
|
for_widget's result even when it's [], showing "Nothing outstanding"
|
|
rather than a distinct not-configured state (the dialog's preview
|
|
endpoint is what actually 400s for that case, same asymmetry calendar
|
|
already has)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from PIL import Image
|
|
from sqlalchemy.orm import Session
|
|
|
|
from ..calendar_render import _build_tasks
|
|
from ..models import Frame, TaskWidgetConfig, Widget
|
|
from ..routers.common import get_or_refresh_tasks_for_widget
|
|
|
|
ACTION_LABELS: dict[str, str] = {}
|
|
|
|
|
|
def render(db: Session, frame: Frame, widget: Widget, target_w: int, target_h: int,
|
|
is_normal_wake: bool = True) -> Image.Image:
|
|
"""is_normal_wake is unused here -- see app/widgets/photos.py's
|
|
identical note; every widget type's render() shares one call
|
|
signature regardless of which ones actually care."""
|
|
tasks = get_or_refresh_tasks_for_widget(db, frame, widget)
|
|
cfg = db.get(TaskWidgetConfig, widget.id)
|
|
return _build_tasks(tasks, target_w, target_h, frame.palette_rgb, cfg.name or "Tasks")
|
|
|
|
|
|
ACTIONS: dict = {}
|