Displaying readouts is working
This commit is contained in:
35
app/views/measurements/_options.html.erb
Normal file
35
app/views/measurements/_options.html.erb
Normal file
@@ -0,0 +1,35 @@
|
||||
<fieldset id="options" class="collapsible">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
|
||||
<div>
|
||||
<%= form_tag toggle_quantity_project_measurements_path(@project),
|
||||
id: 'quantity-toggle-form', name: 'quantity-toggle-form',
|
||||
method: :post, remote: true do %>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width:100%"></td>
|
||||
<td>
|
||||
<%= select_tag 'id', quantity_toggle_options %>
|
||||
</td>
|
||||
<td>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<table class="list" style="border:none; width:100%">
|
||||
<tr>
|
||||
<% total_width = 3 + @quantities.length %>
|
||||
<td style="visibility: hidden; border: none; width:<%= 3 * 100/total_width%>%"></td>
|
||||
<% @quantities.each do |q| %>
|
||||
<td class="action" style="width:<%= 100/total_width %>%">
|
||||
<%= link_to l(:button_hide),
|
||||
toggle_quantity_project_measurements_path(@project, id: q.id),
|
||||
{class: "icon icon-close", method: :post, remote: true} %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -1,25 +1,25 @@
|
||||
<% if @readouts.any? %>
|
||||
<% 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_name) %></th>
|
||||
<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>
|
||||
<% @readouts.each do |m, values| %>
|
||||
<% @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>
|
||||
<% values.each do |*, value| %>
|
||||
<td class="primary value"><%= value %></td>
|
||||
<% @requested_r[index].each do |*, value| %>
|
||||
<td class="primary value"><%= format_value(value) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
@@ -27,19 +27,19 @@
|
||||
<td 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>
|
||||
<% values.each do |q_name, *| %>
|
||||
<% @requested_r[index].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>
|
||||
<% @requested_r[index].each do |*, value| %>
|
||||
<td class="primary value"><%= format_value(value) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
||||
<% extras = @extra_readouts[i] %>
|
||||
<% extras.each_slice(@quantities.length).with_index do |values, index| %>
|
||||
<% next unless @quantities.length > 0 %>
|
||||
<% @extra_r[index].each_slice(@quantities.length).with_index do |values| %>
|
||||
<tr class="extra <%= row_class %>" style="display:none">
|
||||
<td class="space"></td>
|
||||
<% values.each do |q_name, *| %>
|
||||
@@ -52,7 +52,7 @@
|
||||
<tr class="extra <%= row_class %>" style="display:none">
|
||||
<td class="space"></td>
|
||||
<% values.each do |*, value| %>
|
||||
<td class="extra value"><%= value %></td>
|
||||
<td class="extra value"><%= format_value(value) %></td>
|
||||
<% end %>
|
||||
<% if @quantities.length > values.length %>
|
||||
<td class="space" colspan="<%= @quantities.length-values.length %>"></td>
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
>
|
||||
<%= @measurements.first.name %>
|
||||
</h2>
|
||||
<div id='measurements'>
|
||||
<%= render partial: 'measurements/index' %>
|
||||
<div id='readouts'>
|
||||
<%= render partial: 'measurements/readouts' %>
|
||||
</div>
|
||||
|
||||
3
app/views/measurements/toggle_quantity.js.erb
Normal file
3
app/views/measurements/toggle_quantity.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
$('div[id^=flash_]').remove();
|
||||
$('#content').prepend('<%= escape_javascript(render_flash_messages) %>');
|
||||
$('#readouts').html('<%= escape_javascript(render partial: 'measurements/readouts') %>');
|
||||
Reference in New Issue
Block a user