86 lines
3.4 KiB
Plaintext
86 lines
3.4 KiB
Plaintext
<%= render partial: 'foods/filters',
|
|
locals: {url: filter_project_foods_path(@project, view: :nutrients)} %>
|
|
|
|
<% if @foods.any? %>
|
|
<%= render partial: 'foods/options' %>
|
|
|
|
<% formulas = @quantities.map { |q| q.formula } %>
|
|
<% formulas.unshift(@filter_q.formula) if @filter_q %>
|
|
<%= error_messages_for *formulas %>
|
|
|
|
<table class="nutrients list odd-even">
|
|
<thead>
|
|
<tr>
|
|
<% total_width = 4 + @quantities.length %>
|
|
<th style="width:<%= 3 * 100/total_width%>%"><%= l(:field_name) %></th>
|
|
<% @quantities.each do |q| %>
|
|
<th style="width:<%= 100/total_width %>%" class="closable ellipsible">
|
|
<div style="float:right;position:relative;">
|
|
<%= link_to '',
|
|
toggle_exposure_project_foods_path(@project, quantity_id: q.id),
|
|
{class: "icon icon-close", method: :post, remote: true} %>
|
|
</div>
|
|
<%= q.name %>
|
|
</th>
|
|
<% end %>
|
|
<th style="width:<%= 100/total_width %>%"><%= l(:field_action) %></th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<% @foods.each_with_index do |f, index| %>
|
|
<% row_class = "food#{' hidden' if f.hidden} #{cycle('odd', 'even')}" %>
|
|
<tr id="food-<%= f.id %>" class="primary <%= row_class %>">
|
|
<td class="name ellipsible" style="cursor: pointer;"
|
|
onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', '.food').toggle(); return false;">
|
|
<span class="icon icon-bullet-closed"><%= f.name %></span>
|
|
</td>
|
|
<% @requested_n[index].each do |*, value| %>
|
|
<td class="primary value ellipsible"><%= format_value(value) %></td>
|
|
<% end %>
|
|
<td class="action unwrappable"><%= action_links(f, :nutrients) %></td>
|
|
</tr>
|
|
|
|
<tr class="<%= row_class %>" style="display:none">
|
|
<% if @quantities.length > 0
|
|
rows = (@extra_n[index].length - 1) / @quantities.length + 2
|
|
else
|
|
rows = 1
|
|
end %>
|
|
<td rowspan="<%= rows %>" class="name ellipsible" style="cursor: pointer;"
|
|
onclick="$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', '.food').toggle(); return false;">
|
|
<span class="icon icon-bullet-open"><%= f.name %></span>
|
|
</td>
|
|
<% @requested_n[index].each do |q, value| %>
|
|
<td class="primary quantity ellipsible">
|
|
<%= q.name %>
|
|
<p class="value"><%= format_value(value) %></p>
|
|
</td>
|
|
<% end %>
|
|
<td rowspan="<%= rows %>" class="action unwrappable">
|
|
<%= action_links(f, :nutrients) %>
|
|
</td>
|
|
</tr>
|
|
|
|
<% next unless @quantities.length > 0 %>
|
|
<% @extra_n[index].each_slice(@quantities.length) do |values| %>
|
|
<tr class="extra <%= row_class %>" style="display:none">
|
|
<% values.each do |q, value| %>
|
|
<td class="extra quantity ellipsible">
|
|
<%= q.name if value %>
|
|
<p class="value"><%= format_value(value) %></p>
|
|
</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 %>
|