1
0

Measurement index/form running

This commit is contained in:
cryptogopher 2019-11-16 18:47:53 +01:00
parent 22aeda720d
commit a619b74dce
3 changed files with 20 additions and 1 deletions

View File

@ -1,2 +1,19 @@
module MeasurementsHelper
def quantity_options
nested_set_options(@project.quantities.measurement) do |q|
raw("#{' ' * q.level}#{q.name}")
end
end
def unit_options
@project.units.map do |u|
[u.shortname, u.id]
end
end
def source_options
@project.sources.map do |s|
[s.name, s.id]
end
end
end

View File

@ -9,7 +9,7 @@
<div class="box tabular">
<p><%= f.text_field :name, size: 40, required: true %></p>
<p><%= f.select :source_id, source_options, required: false, include_blank: true %></p>
<% @measurements.readouts.each_with_index do |r, index| %>
<% @measurement.readouts.each_with_index do |r, index| %>
<%= f.fields_for 'readouts_attributes', r, index: '' do |ff| %>
<p class="readout">
<%= ff.select :quantity_id, quantity_options,

View File

@ -53,6 +53,8 @@ en:
measurements:
form:
heading_new_measurement: 'New measurement'
button_add_readout: 'Add readout'
button_delete_readout: 'Delete'
index:
heading: 'Measurements'
link_new_measurement: 'New measurement'