Skip to content

save without reload across project, garden, and album forms

Created by: jedmund

Stacked on #88.

Summary

  • ProjectForm, GardenItemForm, and AlbumForm now use replaceState instead of goto after first save in create mode
  • each form keeps the loaded record locally and transitions mode from '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
  • mode and the loaded record (project / item / album) are now shadowed as local $state so 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. If pendingMediaIds exist, they still post to /api/albums/[id]/media after 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 check net error count unchanged at 118.

Merge request reports

Loading