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/measurements/_readouts.html.erb
2019-12-21 18:01:46 +01:00

64 lines
2.6 KiB
Plaintext

<% if @measurements.any? %>
<%= render partial: 'measurements/options' %>
<table class="readouts list odd-even">
<thead>
<tr>
<% total_width = 3 + @quantities.length %>
<th style="width:<%= 3 * 100/total_width%>%"><%= l(:field_taken_at_date) %></th>
<% @quantities.each do |q| %>
<th style="width:<%= 100/total_width %>%"><%= q.name %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @measurements.each_with_index do |m, index| %>
<% row_class = "measurement #{cycle('odd', 'even')}" %>
<tr id="measurement-<%= m.id %>" class="primary <%= row_class %>">
<td class="date" style="cursor: pointer;" onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); return false;">
<span class="icon icon-bullet-closed"><%= format_datetime(m) %></span>
</td>
<% @requested_r[index].each do |*, value| %>
<td class="primary value"><%= format_value(value) %></td>
<% end %>
</tr>
<tr class="<%= row_class %>" style="display:none">
<% if @quantities.length > 0
rows = (@extra_r[index].length - 1) / @quantities.length + 2
else
rows = 1
end %>
<td rowspan="<%= rows %>" class="date" 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"><%= format_datetime(m) %></span>
</td>
<% @requested_r[index].each do |q_name, value| %>
<td class="primary">
<p class="quantity"><%= q_name %></p>
<p class="value"><%= format_value(value) %></p>
</td>
<% end %>
</tr>
<% next unless @quantities.length > 0 %>
<% @extra_r[index].each_slice(@quantities.length).with_index do |values| %>
<tr class="extra <%= row_class %>" style="display:none">
<% values.each do |q_name, value| %>
<td class="extra">
<p class="quantity"><%= q_name %></p>
<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 %>