Displaying amount column in same format as quantities
This commit is contained in:
parent
da11c0f626
commit
e74c707729
@ -85,6 +85,9 @@ class MealsController < ApplicationController
|
||||
foods = @project.meal_foods.compute_quantities(@quantities)
|
||||
ingredients = @project.meal_ingredients
|
||||
|
||||
@amount_mfu_unit = ingredients
|
||||
.each_with_object(Hash.new(0)) { |i, h| h[i.food.ref_unit] += 1 }.max_by(&:last).first
|
||||
|
||||
@nutrients = {}
|
||||
@quantities.each do |q|
|
||||
@nutrients[q] = ingredients.map do |i|
|
||||
|
@ -13,8 +13,8 @@
|
||||
<td class="date" colspan="2" style="width:<%= 3 * 100/total_width %>%" rowspan="2">
|
||||
<h3><%= date == Date.current ? 'Today' : date.strftime('%F') %></h3>
|
||||
</td>
|
||||
<td style="width:<%= 100/total_width %>%; text-align: left;" rowspan="2">
|
||||
<b><%= l(:field_amount) %></b>
|
||||
<td class="quantityhead" style="width:<%= 100/total_width %>%;">
|
||||
<%= l(:field_amount) %>
|
||||
</td>
|
||||
<% @quantities.each do |q| %>
|
||||
<td class="quantityhead closable" style="width: <%= 100/total_width %>%;"
|
||||
@ -25,10 +25,13 @@
|
||||
<td style="width:<%= 100/total_width %>%" rowspan="2"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="quantityhead" style="width:<%= 100/total_width %>%;">
|
||||
<%= "[#{@amount_mfu_unit.shortname}]" %>
|
||||
</td>
|
||||
<% @quantities.each do |q| %>
|
||||
<td class="quantityhead" style="width: <%= 100/total_width %>%;">
|
||||
<% mfu_unit = @nutrients[q][:mfu_unit] %>
|
||||
<%= "[#{ mfu_unit ? mfu_unit.shortname : '-'}]" %>
|
||||
<%= "[#{mfu_unit ? mfu_unit.shortname : '-'}]" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
@ -37,7 +37,8 @@
|
||||
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
|
||||
<td class="name ellipsible" colspan="2"><%= i.food.name %></td>
|
||||
<td class="value ellipsible">
|
||||
<span><%= i.amount %></span>[<%= i.food.ref_unit.shortname %>]
|
||||
<span><%= "%g" % i.amount %></span>
|
||||
<%= "[#{i.food.ref_unit.shortname}]" unless i.food.ref_unit == @amount_mfu_unit %>
|
||||
</td>
|
||||
<% @quantities.each do |q| %>
|
||||
<td class="value ellipsible">
|
||||
|
Reference in New Issue
Block a user