save without reload across project, garden, and album forms
Created by: jedmund
Stacked on #88.
Summary
- ProjectForm, GardenItemForm, and AlbumForm now use
replaceStateinstead ofgotoafter first save in create mode - each form keeps the loaded record locally and transitions
modefrom'create'to'edit'in place — no remount, scroll/focus preserved - the existing post-save state-sync paths (
project = savedProject,populateFromProject,populateFormData,item = savedItem,status = savedItem.status, etc.) now run for both branches; the only difference between create and edit branches is the URL swap -
modeand the loaded record (project/item/album) are now shadowed as local$stateso we can mutate them after save without fighting the prop reactivity
This is PR 3 of the planned admin save-flow refactor. After this, the create→edit transition is consistent and reload-free across all four content types (posts, projects, garden, albums).
Test plan
-
/admin/projects/new: fill in metadata → save → URL silently swaps to/admin/projects/[id]/edit. Form stays mounted; subsequent saves go to PUT. -
/admin/garden/new: same. -
/admin/albums/new: same. IfpendingMediaIdsexist, they still post to/api/albums/[id]/mediaafter first save. -
edit pages for all three: existing save flow unchanged. -
unsaved-changes guard: trying to navigate away with a dirty draft still shows the modal. -
pnpm run checknet error count unchanged at 118.