Skip to content

Hide "Gewasresten achterlaten" input when crop residues are not applicable #508

@SvenVw

Description

@SvenVw

Background & Motivation

In the fdm-app, when configuring or viewing cultivations, users are asked whether crop residues are left on the field ("Gewasresten achterlaten" / m_cropresidue).

However, for many cultivations, crop residues are either not applicable, do not exist, or have an effective organic matter (EOM) value of 0. When the cultivation catalogue indicates that b_lu_eom_residues === 0 (or null), checking this box has no impact on calculations or the organic matter balance. Displaying this input in these scenarios leads to a cluttered UI and can cause confusion for users (farmers and advisors).

Requirements

  • Conditionally render or disable the "Gewasresten achterlaten" inputs based on the cultivation's properties.
  • Look up the selected crop in the cultivation catalogue (b_lu_catalogue -> b_lu_eom_residues).
  • If b_lu_eom_residues === 0 (or null), the input should be hidden (or clearly marked as non-applicable/disabled).
  • Ensure that hiding the checkbox does not cause any React Hook Form / Zod validation errors. If hidden, the value should default to false gracefully upon submission.

Affected Areas

This input appears in several places across the application that need to be updated:

  1. Cultivation Details Form

    • File: fdm-app/app/components/blocks/cultivation/card-details.tsx
    • Action: Hide the m_cropresidue checkbox (Label: "Gewasresten achterlaten") completely when b_lu_eom_residues === 0 with 'invisible' class.
  2. Rotation Table Page

    • File: fdm-app/app/components/blocks/rotation/columns.tsx
    • Action: The "Gewasresten" column allows users to toggle m_cropresidue. For rows where the crop has b_lu_eom_residues === 0, this cell should not render an interactive checkbox/dropdown, but instead should hide it.
    • Related File: fdm-app/app/components/blocks/rotation/table.tsx
  3. Validation Schemas & Actions

    • Files: fdm-app/app/components/blocks/cultivation/schema.ts and fdm-app/app/components/blocks/rotation/schema.ts
    • Action: Ensure that m_cropresidue can gracefully handle being omitted or implicitly set to false when the UI inputs are hidden.
    • Action handler: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.cultivation.$b_lu.tsx and rotation actions.

Technical Context

  • The field in the database/schema is b_lu_eom_residues (from cultivations_catalogue).

Acceptance Criteria

  • Users do not see the "Gewasresten achterlaten" checkbox in the Cultivation Details form for crops with b_lu_eom_residues === 0.
  • In the Rotation Table, the "Gewasresten" input is hidden for applicable rows.
  • Form submission works correctly regardless of whether the checkbox is visible, defaulting to false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions