From 075665c588989ed0decdfb20d83f32b33eed4639 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Fri, 29 Aug 2025 14:22:37 +0200 Subject: Properly implement bed and raft management logic. --- app/views/rafts/_form.html.erb | 23 +++++++++ app/views/rafts/edit.html.erb | 5 ++ app/views/rafts/editor.html.erb | 108 ---------------------------------------- 3 files changed, 28 insertions(+), 108 deletions(-) create mode 100644 app/views/rafts/_form.html.erb create mode 100644 app/views/rafts/edit.html.erb delete mode 100644 app/views/rafts/editor.html.erb (limited to 'app/views/rafts') diff --git a/app/views/rafts/_form.html.erb b/app/views/rafts/_form.html.erb new file mode 100644 index 0000000..7b5d382 --- /dev/null +++ b/app/views/rafts/_form.html.erb @@ -0,0 +1,23 @@ +<%= form_with(model: raft) do |form| %> + <% if raft.errors.any? %> +
+

<%= pluralize(bed.errors.count, "error") %> prohibited this raft from being saved:

+ + +
+ <% end %> + +
+ + <%= form.collection_select :crop_id, @crops, :id, :name, + { include_blank: "Unassigned" }, { class: "form-select" } %> +
+ +
+ <%= form.submit class: "btn btn-primary" %> +
+<% end %> diff --git a/app/views/rafts/edit.html.erb b/app/views/rafts/edit.html.erb new file mode 100644 index 0000000..bf975dc --- /dev/null +++ b/app/views/rafts/edit.html.erb @@ -0,0 +1,5 @@ +<% content_for :title, "Editing bed #{@raft.bed.location}, raft #{@raft.location}" %> + +

Editing bed <%= @raft.bed.location %>, raft <%= @raft.location %>

+ +<%= render "form", raft: @raft %> diff --git a/app/views/rafts/editor.html.erb b/app/views/rafts/editor.html.erb deleted file mode 100644 index cde56d8..0000000 --- a/app/views/rafts/editor.html.erb +++ /dev/null @@ -1,108 +0,0 @@ -
-

Rafts editor

- <%= link_to "Back to dashboard", root_path, class: "btn btn-outline-secondary" %> -
- - -
-
Assign ALL rafts
-
- <%= form_with url: assign_all_rafts_path, method: :patch, class: "row g-2", data: { turbo: false } do %> -
- -
-
- -
- <% end %> -
-
- -
- - - - - <% max_cols = @beds.map { |b| b.rafts.count }.max %> - <% (1..max_cols).each do |i| %> - - <% end %> - - - - <% @beds.each do |bed| %> - - - <% bed.rafts.order(:location).each do |raft| %> - - <% end %> - - <% end %> - -
BedR<%= i %>
<%= bed.location %> - <% if raft.crop %> - <%= raft.crop.name %> - <% else %> - — - <% end %> -
-
- - -<% @beds.each do |bed| %> -
-
- Bed #<%= bed.location %> - <%= form_with url: assign_bed_rafts_path, method: :patch, class: "d-flex gap-2 align-items-center", data: { turbo: false } do %> - - - - <% end %> -
-
-
- - - - - - - - - - <% bed.rafts.order(:location).each do |raft| %> - - - - - - <% end %> - -
RaftCropActions
<%= raft.location %> - <%= form_with url: assign_one_raft_path(raft), method: :patch, class: "d-flex gap-2", data: { turbo: false } do %> - - - <% end %> - - <%= button_to "Clear", assign_one_raft_path(raft, crop_id: ""), method: :patch, - form: { data: { turbo: false } }, class: "btn btn-outline-secondary btn-sm" %> -
-
-
-
-<% end %> -- cgit v1.2.3