feat(templates): allow deleting custom event templates#276
Merged
Conversation
Add a delete action for event templates from the template view page, guarded server-side. System templates (day-off, freeform) are refused because they are looked up by key at runtime, and templates still linked to events are refused because Event.templateId is ON DELETE SET NULL and removing them would orphan those events out of key-filtered queries. Whole-template removal is manager-only; the button is hidden for system templates and disabled while events reference the template. Also fix a missing React key warning in the template edit parts table (bare fragment inside a list) surfaced while testing.
mindsers
force-pushed
the
feat/remove-event-templates
branch
from
July 20, 2026 21:22
c9290cb to
c5a85ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to delete custom event templates from the template view page. Previously templates could only be created and updated, never removed.
Behavior
/settings/congregation/templates/:id), manager-only.day-offandfreeformare looked up bykeyat runtime (createDayOff/createFreeformEvent), so they can never be deleted. The button is hidden for them and the server refuses the intent.Event.templateIdisON DELETE SET NULL. Deleting a template still linked to events would orphan those events (templateId → NULL), and key-filtered queries silently drop null-template rows — the exact class of bug the20260720*migration series had to repair. The server blocks deletion and surfaces the event count; the button is disabled while events reference the template.parts,serviceParts,responsibles, allowed-role rows) handle child cleanup, so a single delete suffices.Implementation
deleteTemplate(db, templateId, congregationId)returns a discriminated result (ok/not-found/system/in-use).view.tsxaction branches onintent(deletevs defaultduplicate); loader exposescanDelete+eventCount; UI adds a destructive button +InlineDeleteDialog.duplicateTemplateinto its ownduplicate-template.server.tsmodule (+ co-located test) to keepevent-templates.server.tsunder the file-size budget.keyon a bare fragment in the template edit parts table.Testing
deleteTemplatecovering success, not-found, system-refusal, in-use-refusal (asserts no delete + reports count), and congregation scoping.