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/nutrients.html.erb
cryptogopher 2f0b34d3fe Extra nutrients are displayed in table cells
Fixed column widths with content ellipsizing
2019-10-31 15:28:32 +01:00

70 lines
2.3 KiB
Plaintext

<% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %>
<% end %>
<div class="contextual">
<%= link_to t(".heading_ingredient_list"), project_ingredients_path(@project),
:class => 'icon icon-list' %>
<%= render :partial => 'ingredients/contextual' %>
</div>
<%= render :partial => 'ingredients/import' %>
<%= render :partial => 'ingredients/form' %>
<h2><%= t ".heading" %></h2>
<% if @primary_nutrients.any? %>
<table class="nutrients list">
<thead>
<tr>
<th style="width:30%"><%= l(:field_name) %></th>
<% @primary_quantities.each do |q| %>
<th style="width:8%"><%= q.name %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @primary_nutrients.each do |i, values| %>
<% row_class = "ingredient #{'hidden' if i.hidden}" %>
<tr id="ingredient-<%= i.id %>" class="primary <%= row_class %>">
<td class="name">
<%= link_to '', '#', {
onclick: "$(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); $(this).toggleClass('icon-bullet-closed'); $(this).toggleClass('icon-bullet-open'); return false;",
class: "icon icon-bullet-closed"
} %>
<%= i.name %>
</td>
<% @primary_quantities.each do |q| %>
<td class="primary value">
<%= values[q.id] || '-' %>
</td>
<% end %>
</tr>
<% @extra_nutrients[i].keys.each_slice(@primary_quantities.length) do |names| %>
<tr class="extra <%= row_class %>" style="display:none">
<td rowspan="2"></td>
<% names.each do |name| %>
<td class="extra name">
<%= name %>
</td>
<% end %>
<% for index in names.length...@primary_quantities.length do %>
<td rowspan="2"></td>
<% end %>
</tr>
<tr class="extra <%= row_class %>" style="display:none">
<% names.each do |name| %>
<% title = %>
<td class="extra value">
<%= @extra_nutrients[i][name] %>
</td>
<% end %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>