Skip to content

Cultures + Lieux: delete varieties and locations (guarded)#89

Merged
guycorbaz merged 1 commit into
mainfrom
fix/variety-and-location-edit-delete
Jun 9, 2026
Merged

Cultures + Lieux: delete varieties and locations (guarded)#89
guycorbaz merged 1 commit into
mainfrom
fix/variety-and-location-edit-delete

Conversation

@guycorbaz

Copy link
Copy Markdown
Owner

Continued pre-production feedback: a variety couldn't be removed, and a location couldn't be deleted — both screens lacked the affordance (same gap as crops had).

Changes

  • Variety delete (Cultures screen): each variety row gets a Supprimer button, routed through the shared confirmation dialog (Confirmations de suppression (dialogue partagé) #61). Blocked — with a localized message — when a planting uses the variety (planting.variety_id is ON DELETE RESTRICT). delete_variety + VarietyRow.in_use disables the button.
  • Location delete (Lieux screen): each location row gets a Supprimer button. Blocked when the location holds child locations or plantings (both FKs are RESTRICT) — exactly as requested: in_use disables the button and delete_location refuses with a localized message. LocationListItem.in_use is computed from children + plantings.
  • New i18n keys (fr/en) for the confirm + in-use/refusal messages.

Verification

  • App tests: delete_variety (unplanted → ok, planted → refused), delete_location (unused leaf → ok, has-children → refused, has-planting → refused).
  • cargo test --workspace (335) green, cargo clippy --workspace --all-targets + cargo fmt --check clean.

Note: crop/location editing of arbitrary fields beyond what's already shipped (crop edit landed in #88) can follow if needed; this PR focuses on the deletion gaps reported.

🤖 Generated with Claude Code

More pre-prod feedback: a variety couldn't be removed, and a location
couldn't be edited/deleted. Both screens lacked the affordance.

- **Variety delete**: each variety row gets a Supprimer button; blocked
  (localized) when a planting uses the variety (FK RESTRICT). `delete_variety`
  + `VarietyRow.in_use`.
- **Location delete**: each location row gets a Supprimer button; **blocked
  when the location holds child locations OR plantings** (both FKs are
  RESTRICT), exactly as requested — `in_use` disables the button and
  `delete_location` refuses with a localized message. `LocationListItem.in_use`
  computed from children + plantings.
- Routed through the shared confirmation dialog (#61); new i18n keys (fr/en).

Tests: delete_variety (unplanted ok / planted refused), delete_location
(unused leaf ok / has-children refused / has-planting refused). Workspace
green, clippy + fmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@guycorbaz guycorbaz merged commit 9e288d7 into main Jun 9, 2026
5 checks passed
@guycorbaz guycorbaz deleted the fix/variety-and-location-edit-delete branch June 9, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant