1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/app/views/ingredients/_list_nutrients.html.erb
cryptogopher cc62ef1002 Added Ingredient comment attribute
Minor view updates
2019-12-27 22:40:07 +01:00

73 lines
2.9 KiB
Plaintext

<%= render partial: 'ingredients/filters',
locals: {url: filter_nutrients_project_ingredients_path(@project)} %>
<% if @nutrients.any? %>
<%= render partial: 'ingredients/options' %>
<table class="nutrients list odd-even">
<thead>
<tr>
<% total_width = 3 + @quantities.length %>
<th style="width:<%= 3 * 100/total_width%>%"><%= l(:field_name) %></th>
<% @quantities.each do |q| %>
<th style="width:<%= 100/total_width %>%"><%= q.name %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @nutrients.each do |i, values| %>
<% row_class = "ingredient#{' hidden' if i.hidden} #{cycle('odd', 'even')}" %>
<tr id="ingredient-<%= i.id %>" class="primary <%= row_class %>">
<td class="name ellipsible" style="cursor: pointer;"
onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); return false;">
<span class="icon icon-bullet-closed"><%= i.name %></span>
</td>
<% values.each do |*, value| %>
<td class="primary value"><%= value %></td>
<% end %>
</tr>
<tr class="<%= row_class %>" style="display:none">
<td class="name" style="cursor: pointer;" onclick="$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', 'tr').toggle(); return false;">
<span class="icon icon-bullet-closed"><%= i.name %></span>
</td>
<% values.each do |q_name, *| %>
<td class="primary quantity"><%= q_name %></td>
<% end %>
</tr>
<tr class="<%= row_class %>" style="display:none">
<td class="space"></td>
<% values.each do |*, value| %>
<td class="primary value"><%= value %></td>
<% end %>
</tr>
<% extras = @extra_nutrients[i] %>
<% extras.each_slice(@quantities.length).with_index do |values, index| %>
<tr class="extra <%= row_class %>" style="display:none">
<td class="space"></td>
<% values.each do |q_name, *| %>
<td class="extra quantity"><%= q_name %></td>
<% end %>
<% if @quantities.length > values.length %>
<td class="space" colspan="<%= @quantities.length-values.length %>"></td>
<% end %>
</tr>
<tr class="extra <%= row_class %>" style="display:none">
<td class="space"></td>
<% values.each do |*, value| %>
<td class="extra value"><%= value %></td>
<% end %>
<% if @quantities.length > values.length %>
<td class="space" colspan="<%= @quantities.length-values.length %>"></td>
<% end %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>