Skip to content

Enhance Field List on Farm Balance Pages with Cultivation Information #616

@SvenVw

Description

@SvenVw

Description

Currently, on the farm balance pages, users see a list of fields in the right-hand card. This list only displays the field name and its area, which provides limited context. We need to enhance this list by displaying the main cultivation (crop) for that year as a badge next to the area. If a field has multiple cultivations (e.g., a main crop and a catch crop / 'vanggewas'), we should indicate this with a "+X" (e.g., "+1") note next to the badge. Clicking this indicator should open a modal showing all cultivations for that field along with their key details.

Current Behavior

  • The right-hand card on farm balance pages shows a list of fields.
  • Each list item only displays the field name and the area (e.g., in hectares).
  • Users cannot see which crops are on the field for the selected year.

Expected Behavior

  • Each field in the list should display a badge representing the main cultivation for the selected year.
  • The main cultivation should be determined using the existing getDefaultCultivation helper function.
  • Clicking the main cultivation badge should open a Modal dialog with details about the cultivation.
  • If a field has more than one cultivation in the selected year, a "+X" note (e.g., "+1") should be displayed next to the badge, which also triggers the modal when clicked.
  • The modal should list all cultivations for that field in the given year (even if there is only one), including the following key details for each:
    • Cultivation / Crop Name
    • Start Date
    • End Date
    • Harvest Date(s)

Technical Details & Context

  • Relevant Routes: This change applies to the balance pages, primarily located at:
    • fdm-app/app/routes/farm.$b_id_farm.$calendar.balance._index.tsx
    • fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsx
    • fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.organic-matter._index.tsx
  • Helper Function: Use getDefaultCultivation from fdm-app/app/lib/cultivation-helpers.ts to identify the main crop to display in the badge.
  • UI Components: Use the design system's Badge component for the main crop and the Dialog / Modal component (from shadcn) for the expanded cultivation details.

Acceptance Criteria

  • The field list on the farm balance pages shows a badge with the main cultivation next to the area.
  • Clicking the main cultivation badge opens a modal dialog.
  • If multiple cultivations exist for a field in the selected year, a "+X" indicator is visible and also opens the modal.
  • The modal displays all cultivations for that field (including cases with only one cultivation), showing start date, end date, and harvest date(s).
  • The implementation correctly uses the getDefaultCultivation helper.

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