Skip to content

Cultures: crop edit + delete, status feedback, dynamic variety title#88

Merged
guycorbaz merged 1 commit into
mainfrom
fix/cultures-crop-edit-and-feedback
Jun 9, 2026
Merged

Cultures: crop edit + delete, status feedback, dynamic variety title#88
guycorbaz merged 1 commit into
mainfrom
fix/cultures-crop-edit-and-feedback

Conversation

@guycorbaz

Copy link
Copy Markdown
Owner

Pre-production feedback on the Cultures screen.

Problems reported

  1. Cannot add a variety to a newly created crop. Root cause: the required harvest-DOY fields were left empty — the 220/280 shown are placeholders, not values — so creation failed validation. (The status banner is wired, but the message wasn't noticed; the form title also wrongly said "annuelle".)
  2. Cannot edit a crop once created — there was no edit/delete affordance at all (not implemented).

Neither is related to #86.

Changes

  • Crop edit + delete (mirrors the existing task-types management pattern):
    • Each crop row gains Modifier / Supprimer buttons.
    • Modifier loads the crop into the form (edit mode: title → "Modifier la culture", Enregistrer / Annuler).
    • Supprimer routes through the shared confirmation dialog (Confirmations de suppression (dialogue partagé) #61).
    • App layer: update_crop, delete_crop (FK-guarded — blocked when a variety is planted, surfaced as a localized "culture utilisée"), get_crop_for_edit. CropRow.in_use disables Delete when the crop has a planted variety.
  • Dynamic variety form title: "Nouvelle variété annuelle / pluriannuelle" now follows the selected crop instead of being hardcoded.
  • New i18n keys (fr/en) for the edit/delete/cancel/save labels, the in-use badge, the confirm + error messages.

Verification

  • cargo test --workspace (330), cargo clippy --workspace --all-targets, cargo fmt --check — all green.
  • App tests cover update_crop / delete_crop / get_crop_for_edit and the delete-refused-when-a-variety-is-planted guard.

🤖 Generated with Claude Code

Pre-prod feedback on the Cultures screen: a created crop couldn't be edited
(no affordance), and adding a variety appeared to do nothing (the required
harvest-DOY fields were left empty — the 220/280 are placeholders — and the
error wasn't obvious).

- **Crop edit + delete** (mirrors the task-types pattern): each crop row now
  has Modifier / Supprimer buttons; Modifier loads the crop into the form
  (edit mode: dynamic title + Save/Cancel), Supprimer routes through the
  shared confirmation dialog (#61). App layer gains `update_crop`,
  `delete_crop` (FK-guarded: blocked when a variety is planted, surfaced as a
  localized "crop in use"), and `get_crop_for_edit`; `CropRow.in_use` disables
  Delete when the crop has a planted variety.
- **Dynamic variety form title**: "Nouvelle variété annuelle/pluriannuelle"
  now follows the selected crop instead of being hardcoded to "annuelle".
- The crop form's submit/cancel + new i18n keys (fr/en).

Tests: update/delete/get_for_edit + the delete-refused-when-planted guard;
workspace green (330), clippy + fmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@guycorbaz guycorbaz merged commit 0538c5e into main Jun 9, 2026
5 checks passed
@guycorbaz guycorbaz deleted the fix/cultures-crop-edit-and-feedback branch June 9, 2026 14:50
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