View raw

1 <% content_for :title, "Crop Allocation" %> 2 3 <h1 class="display-1">Beds and Rafts</h1> 4 5 <%= link_to "Back to dashboard", root_path, class: "btn btn-outline-secondary my-3" %> 6 7 8 <p> 9 Click on a bed row or an individual raft to update the corresponding crop. 10 </p> 11 12 <%= form_with url: bulk_assign_crops_beds_path, 13 method: :patch, 14 local: true do %> 15 <div class="btn-group" role="group" aria-label="Raft crop bulk actions"> 16 <select class="form-select" name="crop_id"> 17 <% @crops.each do |crop| %> 18 <option value="<%= crop.id %>"><%= crop.name.titleize %></option> 19 <% end %> 20 </select> 21 <button type="submit" class="btn btn-outline-primary">Apply to all</button> 22 </div> 23 <% end %> 24 25 <div class="table-responsive"> 26 <table class="table table-sm small text-center align-middle my-3"> 27 <thead> 28 <tr> 29 <th>Bed</th> 30 <% max_cols = @beds.map { |b| b.rafts.count }.max %> 31 <% (1..max_cols).each do |i| %> 32 <th>R<%= i %></th> 33 <% end %> 34 </tr> 35 </thead> 36 <tbody> 37 <% @beds.each do |bed| %> 38 <tr> 39 <th><%= link_to bed.location, edit_bed_path(bed), class: "btn btn-outline-secondary" %></th> 40 <% bed.rafts.each do |raft| %> 41 <td> 42 <%= link_to (raft&.crop&.name || "—"), edit_raft_path(raft), class: "btn btn-sm" %> 43 </td> 44 <% end %> 45 </tr> 46 <% end %> 47 </tbody> 48 </table> 49 </div> 50 51 <%= button_to "Reset crop allocation", reset_seed_crops_beds_path, 52 method: :post, 53 form: { data: { turbo: false } }, 54 class: "btn btn-outline-danger" %> 55