<% content_for :title, "Crop Allocation" %>

Beds and Rafts

<%= link_to "Back to dashboard", root_path, class: "btn btn-outline-secondary my-3" %>

Click on a bed row or an individual raft to update the corresponding crop.

<%= form_with url: bulk_assign_crops_beds_path, method: :patch, local: true do %>
<% end %>
<% max_cols = @beds.map { |b| b.rafts.count }.max %> <% (1..max_cols).each do |i| %> <% end %> <% @beds.each do |bed| %> <% bed.rafts.each do |raft| %> <% end %> <% end %>
BedR<%= i %>
<%= link_to bed.location, edit_bed_path(bed), class: "btn btn-outline-secondary" %> <%= link_to (raft&.crop&.name || "—"), edit_raft_path(raft), class: "btn btn-sm" %>
<%= button_to "Reset crop allocation", reset_seed_crops_beds_path, method: :post, form: { data: { turbo: false } }, class: "btn btn-outline-danger" %>