summaryrefslogtreecommitdiff
path: root/app/views/beds/index.html.erb
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-08-29 14:22:37 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-08-29 14:22:37 +0200
commit075665c588989ed0decdfb20d83f32b33eed4639 (patch)
treed9ec78be7338bd51c895b7fb311f081a7c77c45f /app/views/beds/index.html.erb
parent52b044d6a4278c229992404ad5801769c2d13363 (diff)
Properly implement bed and raft management logic.
Diffstat (limited to 'app/views/beds/index.html.erb')
-rw-r--r--app/views/beds/index.html.erb54
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" %>
Copyright 2019--2025 Marius PETER