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)
|
foods = @project.meal_foods.compute_quantities(@quantities)
|
||||||
ingredients = @project.meal_ingredients
|
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 = {}
|
@nutrients = {}
|
||||||
@quantities.each do |q|
|
@quantities.each do |q|
|
||||||
@nutrients[q] = ingredients.map do |i|
|
@nutrients[q] = ingredients.map do |i|
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
<td class="date" colspan="2" style="width:<%= 3 * 100/total_width %>%" rowspan="2">
|
<td class="date" colspan="2" style="width:<%= 3 * 100/total_width %>%" rowspan="2">
|
||||||
<h3><%= date == Date.current ? 'Today' : date.strftime('%F') %></h3>
|
<h3><%= date == Date.current ? 'Today' : date.strftime('%F') %></h3>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:<%= 100/total_width %>%; text-align: left;" rowspan="2">
|
<td class="quantityhead" style="width:<%= 100/total_width %>%;">
|
||||||
<b><%= l(:field_amount) %></b>
|
<%= l(:field_amount) %>
|
||||||
</td>
|
</td>
|
||||||
<% @quantities.each do |q| %>
|
<% @quantities.each do |q| %>
|
||||||
<td class="quantityhead closable" style="width: <%= 100/total_width %>%;"
|
<td class="quantityhead closable" style="width: <%= 100/total_width %>%;"
|
||||||
@ -25,6 +25,9 @@
|
|||||||
<td style="width:<%= 100/total_width %>%" rowspan="2"></td>
|
<td style="width:<%= 100/total_width %>%" rowspan="2"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="quantityhead" style="width:<%= 100/total_width %>%;">
|
||||||
|
<%= "[#{@amount_mfu_unit.shortname}]" %>
|
||||||
|
</td>
|
||||||
<% @quantities.each do |q| %>
|
<% @quantities.each do |q| %>
|
||||||
<td class="quantityhead" style="width: <%= 100/total_width %>%;">
|
<td class="quantityhead" style="width: <%= 100/total_width %>%;">
|
||||||
<% mfu_unit = @nutrients[q][:mfu_unit] %>
|
<% mfu_unit = @nutrients[q][:mfu_unit] %>
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
|
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
|
||||||
<td class="name ellipsible" colspan="2"><%= i.food.name %></td>
|
<td class="name ellipsible" colspan="2"><%= i.food.name %></td>
|
||||||
<td class="value ellipsible">
|
<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>
|
</td>
|
||||||
<% @quantities.each do |q| %>
|
<% @quantities.each do |q| %>
|
||||||
<td class="value ellipsible">
|
<td class="value ellipsible">
|
||||||
|
Reference in New Issue
Block a user