update ingredient list
This commit is contained in:
parent
c0d43171a4
commit
30726ec1b8
17
app/decorators/ingredient_decorator.rb
Normal file
17
app/decorators/ingredient_decorator.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class IngredientDecorator < BaseDecorator
|
||||||
|
|
||||||
|
def ndbn_check
|
||||||
|
if ndbn.present?
|
||||||
|
"<span class =\"glyphicon glyphicon-ok\"></span>".html_safe
|
||||||
|
else
|
||||||
|
''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def density
|
||||||
|
if wrapped.density.present?
|
||||||
|
value = UnitConversion::parse(wrapped.density)
|
||||||
|
value.convert('oz/cup').change_formatter(UnitConversion::DecimalFormatter.new).pretty_value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -16,22 +16,22 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>USDA NDBN</th>
|
<th>USDA</th>
|
||||||
<th>KCal per 100g</th>
|
<th>KCal per 100g</th>
|
||||||
<th>Density</th>
|
<th>Density (oz/cup)</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @ingredients.each do |ingredient| %>
|
<% decorate(@ingredients, IngredientDecorator).each do |ingredient| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to ingredient.name, edit_ingredient_path(ingredient) %></td>
|
<td><%= link_to ingredient.name, edit_ingredient_path(ingredient) %></td>
|
||||||
<td><%= ingredient.ndbn %></td>
|
<td><%= ingredient.ndbn_check %></td>
|
||||||
<td><%= ingredient.kcal %></td>
|
<td><%= ingredient.kcal %></td>
|
||||||
<td><%= ingredient.density %></td>
|
<td><%= ingredient.density %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' do %>
|
<%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %>
|
||||||
<span class="glyphicon glyphicon-remove"></span>
|
<span class="glyphicon glyphicon-remove"></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user