add dropdowns for client, owner, builder in subproject form

This commit is contained in:
Stefan Tollkühn
2025-07-24 18:14:36 +02:00
parent 0aab8a43c0
commit 78b53e58ce
2 changed files with 9 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
module SubprojectsHelper
def subproject_form_fields
[:subproject_name, :project_id, :client_id, :owner_id, :builder_id]
[:subproject_name, :project, :client, :owner, :builder]
end
def subproject_view_fields

View File

@@ -14,7 +14,14 @@
<% subproject_form_fields.each do |attrib| %>
<div>
<%= form.label attrib, style: "display: block" %>
<%= form.text_field attrib, value: subproject.send(attrib) %>
<% case attrib %>
<% when :project %>
<%= form.collection_select :project_id, Project.all, :id, -> (project) { "#{project.name}" }, prompt: "Select Project" %>
<% when :client, :owner, :builder %>
<%= form.collection_select "#{attrib}_id", Client.all, :id, -> (client) { "#{client.company_name} (#{client.lastname}, #{client.firstname})" }, prompt: "Select #{attrib.capitalize}" %>
<% else %>
<%= form.text_field attrib, value: subproject.send(attrib) %>
<% end %>
</div>
<% end %>