diff options
Diffstat (limited to 'app/views/beds/index.html.erb')
-rw-r--r-- | app/views/beds/index.html.erb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/app/views/beds/index.html.erb b/app/views/beds/index.html.erb new file mode 100644 index 0000000..e645dc5 --- /dev/null +++ b/app/views/beds/index.html.erb @@ -0,0 +1,54 @@ +<% content_for :title, "Crop Allocation" %> + +<h1 class="display-1">Beds and Rafts</h1> + +<%= link_to "Back to dashboard", root_path, class: "btn btn-outline-secondary my-3" %> + + +<p> + Click on a bed row or an individual raft to update the corresponding crop. +</p> + +<%= form_with url: bulk_assign_crops_beds_path, + method: :patch, + local: true do %> + <div class="btn-group" role="group" aria-label="Raft crop bulk actions"> + <select class="form-select" name="crop_id"> + <% @crops.each do |crop| %> + <option value="<%= crop.id %>"><%= crop.name.titleize %></option> + <% end %> + </select> + <button type="submit" class="btn btn-outline-primary">Apply to all</button> + </div> +<% end %> + +<div class="table-responsive"> + <table class="table table-sm small text-center align-middle my-3"> + <thead> + <tr> + <th>Bed</th> + <% max_cols = @beds.map { |b| b.rafts.count }.max %> + <% (1..max_cols).each do |i| %> + <th>R<%= i %></th> + <% end %> + </tr> + </thead> + <tbody> + <% @beds.each do |bed| %> + <tr> + <th><%= link_to bed.location, edit_bed_path(bed), class: "btn btn-outline-secondary" %></th> + <% bed.rafts.each do |raft| %> + <td> + <%= link_to (raft&.crop&.name || "—"), edit_raft_path(raft), class: "btn btn-sm" %> + </td> + <% end %> + </tr> + <% end %> + </tbody> + </table> +</div> + +<%= button_to "Reset crop allocation", reset_seed_crops_beds_path, + method: :post, + form: { data: { turbo: false } }, + class: "btn btn-outline-danger" %> |