From 8bafba7f9d806a309d10eb4ab9a8868bb9dcfeb7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 22 Feb 2026 00:08:58 +0000 Subject: [PATCH] Ensure "mark as failed" option is available when viewing a crop This change adds the "mark as failed" action to the crop view in two places: 1. In the "Crop Actions" button group, a new "Mark as failed" button is added if the current member has active plantings of that crop. Clicking it opens a modal to select which planting failed. 2. In the "See who's planted" list, an "Actions" dropdown is added to any plantings owned by the current member, which includes the "Mark as failed" option. A new partial `app/views/plantings/_failed_modal.html.haml` was created to handle the planting selection modal. `app/views/crops/_actions.html.haml` and `app/views/crops/_plantings.html.haml` were updated to include these new actions. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com> --- app/views/crops/_actions.html.haml | 3 +++ app/views/crops/_plantings.html.haml | 2 ++ app/views/plantings/_failed_modal.html.haml | 26 +++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 app/views/plantings/_failed_modal.html.haml diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 71d8340a0..9f0d2d3a2 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,6 +1,9 @@ - if crop.approved? && signed_in? + - active_plantings = current_member.plantings.where(crop: crop).active .btn-group.crop-actions{"aria-label" => "Crop Actions", role: "group"} = render 'plantings/modal', planting: Planting.new(crop: crop, owner: current_member) = render 'harvests/modal', harvest: Harvest.new(crop: @crop, owner: current_member) = render 'seeds/modal', seed: Seed.new(crop: @crop, owner: current_member) + - if active_plantings.any? + = render 'plantings/failed_modal', crop: crop, active_plantings: active_plantings diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index 9e960f2dd..12ebace39 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -8,6 +8,8 @@ = link_to planting_path(planting), class: 'card-link' do = planting_icon = planting + - if can?(:edit, planting) + .float-right= render 'plantings/actions', planting: planting .float-right= render 'members/location', member: planting.owner .card-footer - if crop.approved? diff --git a/app/views/plantings/_failed_modal.html.haml b/app/views/plantings/_failed_modal.html.haml new file mode 100644 index 000000000..8291bdf10 --- /dev/null +++ b/app/views/plantings/_failed_modal.html.haml @@ -0,0 +1,26 @@ +#modelFailedPlantingForm.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "failed-planting-button", role: "dialog", tabindex: "-1"} + .modal-dialog{role: "document"} + .modal-content + .modal-header.text-center + %h4.modal-title.w-100.font-weight-bold Mark #{crop.name} planting as failed + %button.close{"aria-label" => "Close", "data-bs-dismiss" => "modal", type: "button"} + %span{"aria-hidden" => "true"} × + .modal-body + %p Which planting would you like to mark as failed? + + %ul.list-group + - active_plantings.each do |planting| + %li.list-group-item + = link_to planting_path(planting, planting: {failed: 1}), method: :put do + .d-flex.justify-content-between + %span + %h4= planting.garden.name + %p Planted #{planting.planted_at} + %span + = finished_icon + .mt-3.text-right + = link_to 'cancel', '', "data-bs-dismiss" => "modal", class: 'btn btn-secondary' + +%a.btn#failed-planting-button{"data-bs-target" => "#modelFailedPlantingForm", "data-bs-toggle" => "modal", href: ""} + = finished_icon + Mark as failed