Dispplaying units of computed values
Fixed formula error messages display when filter formula not given
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
module BodyTrackersHelper
|
||||
def format_value(value)
|
||||
amount, unitname = value
|
||||
amount, unit = value
|
||||
case
|
||||
when amount.nil?
|
||||
'-'
|
||||
when amount.nan?
|
||||
'?'
|
||||
else
|
||||
"#{amount} [#{unitname || '-'}]"
|
||||
"#{amount} [#{unit.shortname || '-'}]"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Formula < ActiveRecord::Base
|
||||
"length.times.map { |index| #{p[:content]} }" : p[:content]
|
||||
args << get_binding(quantities, args, length).eval(code)
|
||||
end
|
||||
args.last.map { |v| [v, nil] }
|
||||
args.last.map { |v| [v, self.unit] }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
locals: {url: filter_project_ingredients_path(@project)} %>
|
||||
|
||||
<% if @ingredients.any? { |i| i.persisted? } %>
|
||||
<%= error_messages_for @formula_q.formula %>
|
||||
<%= error_messages_for @formula_q.formula if @formula_q %>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
<% if @ingredients.any? %>
|
||||
<%= render partial: 'ingredients/options' %>
|
||||
|
||||
<%= error_messages_for @formula_q.formula, *@quantities.map { |q| q.formula } %>
|
||||
<% formulas = @quantities.map { |q| q.formula } %>
|
||||
<% formulas.unshift(@formula_q.formula) if @formula_q %>
|
||||
<%= error_messages_for *formulas %>
|
||||
|
||||
<table class="nutrients list odd-even">
|
||||
<thead>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
locals: {url: filter_project_measurements_path(@project)} %>
|
||||
|
||||
<% if @measurements.any? { |m| m.persisted? } %>
|
||||
<%= error_messages_for @formula_q.formula %>
|
||||
<%= error_messages_for @formula_q.formula if @formula_q %>
|
||||
|
||||
<table class="list">
|
||||
<thead>
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
<% if @measurements.any? %>
|
||||
<%= render partial: 'measurements/options' %>
|
||||
|
||||
<%= error_messages_for @formula_q.formula, *@quantities.map { |q| q.formula } %>
|
||||
<% formulas = @quantities.map { |q| q.formula } %>
|
||||
<% formulas.unshift(@formula_q.formula) if @formula_q %>
|
||||
<%= error_messages_for *formulas %>
|
||||
|
||||
<table class="readouts list odd-even">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user