GET /api/templates (optional ?templateGroupId= filter), GET/POST/DELETE /api/templates[/{id}]
GET /api/templates/{id}/items (404-guarded, startTime-sorted, carries blockName + minutes for end-time display)
PUT /api/templates/{id} — full replace via ReplaceTemplateItems (server-side overlap validation)
POST /api/templates/{id}/copy + POST /api/blocks/{id}/copy (CopyBlock deep-copies items+watermarks+graphics — verified)
Root-cause fixes in Application handlers (same latent-500 class as S1): CreateTemplateHandler now validates group existence; ReplaceTemplateItemsHandler now 422s on unknown blockId (was KeyNotFoundException → 500, confirmed live) and rejects midnight-crossing items (were accepted then silently dropped/deleted by the items query's invalid-item filter).
SPA
web/src/api/templates.ts + tests; /app/templates grouped list (create/copy/delete dialogs) + /app/templates/{id} editor: add-content row (block-group → block → 5-min start-time select), time-sorted items table with computed end times, client-side overlap + midnight-crossing warnings (Save disabled), block picker excludes the synthesized "(none)" placeholder rows. Deviation from Blazor stated in-code: table editor instead of the drag calendar (server stays authoritative).
Adds TemplateController mirroring BlockController: groups CRUD, template
CRUD, item replace (PUT full-replace via ReplaceTemplateItems), and a
copy endpoint. Also wires the missing POST /api/blocks/{id}/copy since
CopyBlock's CQRS shape is directly analogous to CopyTemplate.
Fixes CreateTemplateHandler to validate the target template group exists
before insert (previously an unhandled FK violation -> 500), matching the
CreateBlockHandler fix (1e34e00e) for the same class of bug.
New DTOs in ErsatzTV.Core/Api/Scheduling; TimeSpan start times serialize
the same way as PlayoutResponseModel.DailyRebuildTime.
#144 S2 (#162)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a ChicoryTV Templates screen under /app/templates: grouped template
list with group/template create, copy, and delete, and a
/app/templates/{id} editor (name, add-content row that picks a block
group -> block -> five-minute start time, a time-sorted item table with
remove, and a client-side overlap warning that mirrors
ReplaceTemplateItemsHandler's server-side check before allowing save).
Deviates from the Blazor TemplateEditor.razor's drag-to-place day
calendar: uses a plain sorted table + picker row instead, per the S2
spec (parity, not a pixel port).
Adds web/src/api/templates.ts client + copyBlock to blocks.ts (S1 left
the block-copy endpoint unwired; CopyBlock's CQRS shape is identical to
CopyTemplate so it rides along here), plus regenerated v1.d.ts types.
#144 S2 (#162)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PUT /api/templates/{id} with an unknown blockId threw KeyNotFoundException
(HTTP 500) because the dictionary indexer assumed every referenced block
had been loaded. Validate all blockIds exist before building the overlap
list and return a 422 with "[BlockId] {id} does not exist." on failure,
matching ReplaceBlockItemsHandler's message convention.
Also reject items whose start time + block duration crosses midnight
(> 24:00). Previously these were silently accepted by PUT, then dropped
by GetTemplateItemsHandler's end-of-day filter on every subsequent GET,
so a saved item would vanish and be deleted on the next save.
GET /api/blocks emits a synthesized negative-id "(none)" row per empty
block group; the block picker was including it as a selectable option.
Filter to b.id > 0, mirroring the backend's real block ids.
Also mirror ReplaceTemplateItemsHandler's new end-of-day validation on
the client: flag an item whose start time + block duration crosses
midnight and disable Save, same as the existing overlap-warning path.
Adds coverage: block picker excludes negative-id rows; validate() flags
a midnight-crossing item.
timothy
merged commit 86f280f9d0 into main2026-07-07 19:00:45 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Slice S2 of the #162 scheduling REST plan (parity issue #144): Templates + Template Groups, plus the S1-deferred block copy.
API (new
TemplateController, mirrors BlockController)GET/POST /api/templates/groups,DELETE /api/templates/groups/{id}(cascade documented)GET /api/templates(optional?templateGroupId=filter),GET/POST/DELETE /api/templates[/{id}]GET /api/templates/{id}/items(404-guarded, startTime-sorted, carries blockName + minutes for end-time display)PUT /api/templates/{id}— full replace via ReplaceTemplateItems (server-side overlap validation)POST /api/templates/{id}/copy+POST /api/blocks/{id}/copy(CopyBlock deep-copies items+watermarks+graphics — verified)CreateTemplateHandlernow validates group existence;ReplaceTemplateItemsHandlernow 422s on unknown blockId (was KeyNotFoundException → 500, confirmed live) and rejects midnight-crossing items (were accepted then silently dropped/deleted by the items query's invalid-item filter).SPA
web/src/api/templates.ts+ tests;/app/templatesgrouped list (create/copy/delete dialogs) +/app/templates/{id}editor: add-content row (block-group → block → 5-min start-time select), time-sorted items table with computed end times, client-side overlap + midnight-crossing warnings (Save disabled), block picker excludes the synthesized "(none)" placeholder rows. Deviation from Blazor stated in-code: table editor instead of the drag calendar (server stays authoritative).Verification
Part of #144 / #162 (slice S2 — do not auto-close).
🤖 Generated with Claude Code
Adds TemplateController mirroring BlockController: groups CRUD, template CRUD, item replace (PUT full-replace via ReplaceTemplateItems), and a copy endpoint. Also wires the missing POST /api/blocks/{id}/copy since CopyBlock's CQRS shape is directly analogous to CopyTemplate. Fixes CreateTemplateHandler to validate the target template group exists before insert (previously an unhandled FK violation -> 500), matching the CreateBlockHandler fix (1e34e00e) for the same class of bug. New DTOs in ErsatzTV.Core/Api/Scheduling; TimeSpan start times serialize the same way as PlayoutResponseModel.DailyRebuildTime. #144 S2 (#162) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>Adds a ChicoryTV Templates screen under /app/templates: grouped template list with group/template create, copy, and delete, and a /app/templates/{id} editor (name, add-content row that picks a block group -> block -> five-minute start time, a time-sorted item table with remove, and a client-side overlap warning that mirrors ReplaceTemplateItemsHandler's server-side check before allowing save). Deviates from the Blazor TemplateEditor.razor's drag-to-place day calendar: uses a plain sorted table + picker row instead, per the S2 spec (parity, not a pixel port). Adds web/src/api/templates.ts client + copyBlock to blocks.ts (S1 left the block-copy endpoint unwired; CopyBlock's CQRS shape is identical to CopyTemplate so it rides along here), plus regenerated v1.d.ts types. #144 S2 (#162) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>PUT /api/templates/{id} with an unknown blockId threw KeyNotFoundException (HTTP 500) because the dictionary indexer assumed every referenced block had been loaded. Validate all blockIds exist before building the overlap list and return a 422 with "[BlockId] {id} does not exist." on failure, matching ReplaceBlockItemsHandler's message convention. Also reject items whose start time + block duration crosses midnight (> 24:00). Previously these were silently accepted by PUT, then dropped by GetTemplateItemsHandler's end-of-day filter on every subsequent GET, so a saved item would vanish and be deleted on the next save.