1
0

compute_quantities: allow indirect associations and model dependencies

This commit is contained in:
cryptogopher
2020-05-10 18:06:32 +02:00
parent 9d19890f6f
commit 1f5ea1cfb6
10 changed files with 129 additions and 112 deletions

View File

@@ -27,7 +27,7 @@
<tr class="header">
<td class="quantityhead"><%= "[#{@amount_mfu_unit.shortname}]" %></td>
<% @quantities.each do |q| %>
<% mfu_unit = @nutrients[q][:mfu_unit] %>
<% mfu_unit = @ingredient_summary[:mfu_unit][q] %>
<td class="quantityhead"><%= "[#{mfu_unit ? mfu_unit.shortname : '-'}]" %></td>
<% end %>
</tr>

View File

@@ -37,7 +37,7 @@
<td class="value ellipsible" style="border-left: none;"></td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(@nutrient_summary[q][m], @nutrients[q][:precision]) %>
<%= format_value(@ingredient_summary[m][q], @ingredient_summary[:precision][q]) %>
</td>
<% end %>

View File

@@ -7,7 +7,7 @@
<td class="value ellipsible" style="border-left: none;"></td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(@nutrient_summary[q][date], @nutrients[q][:precision]) %>
<%= format_value(@ingredient_summary[date][q], @ingredient_summary[:precision][q]) %>
</td>
<% end %>
<td></td>

View File

@@ -6,7 +6,8 @@
</td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(*@nutrients[q].values_at(i, :precision, :mfu_unit)) %>
<%= format_value(@ingredients[i][q], @ingredient_summary[:precision][q],
@ingredient_summary[:mfu_unit][q]) %>
</td>
<% end %>
<td class="action unwrappable" style="width: 1%; text-align: right;">