Create Readouts controller
Move #readouts + #toggle_exposure from Measurements to Readouts
This commit is contained in:
@@ -18,10 +18,10 @@
|
||||
<% @measurements.each do |m| %>
|
||||
<% next if m.new_record? %>
|
||||
<tr id="measurement-<%= m.id %>" class="primary measurement">
|
||||
<td class="topleft unwrappable"><%= format_datetime(m) %></td>
|
||||
<td class="topleft unwrappable"><%= format_datetime(m.taken_at) %></td>
|
||||
<td class="topleft">
|
||||
<div style="float:left;">
|
||||
<%= link_to m.routine.name, readouts_measurement_routine_path(m.routine) %>
|
||||
<%= link_to m.routine.name, measurement_routine_readouts_path(m.routine) %>
|
||||
</div>
|
||||
<div style="float:right;">
|
||||
<small><%= " (#{pluralize(m.readouts.size, 'readout')})" %></small>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<fieldset id="options" class="collapsible">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
|
||||
<div>
|
||||
<%= form_tag toggle_exposure_measurement_routine_path(@routine, @view_params),
|
||||
id: 'toggle-exposure-form', name: 'toggle-exposure-form',
|
||||
method: :post, remote: true do %>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width:100%"></td>
|
||||
<td><%= select_tag 'quantity_id',
|
||||
toggle_exposure_options(@routine.quantities, :measurement) %></td>
|
||||
<td><%= submit_tag l(:button_add) %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -1,86 +0,0 @@
|
||||
<%= render partial: 'measurements/filters',
|
||||
locals: {url: filter_project_measurements_path(@project, @view_params)} %>
|
||||
|
||||
<% if @measurements.any? %>
|
||||
<%= render partial: 'measurements/options' %>
|
||||
|
||||
<% formulas = @quantities.map { |q| q.formula } %>
|
||||
<% formulas.unshift(@filter_q.formula) if @filter_q %>
|
||||
<%= error_messages_for *formulas %>
|
||||
|
||||
<table class="readouts list odd-even">
|
||||
<thead>
|
||||
<tr>
|
||||
<% total_width = 3 + @quantities.length %>
|
||||
<th style="width:<%= 2 * 100/total_width%>%"><%= l(:field_taken_at_date) %></th>
|
||||
<% @quantities.each do |q| %>
|
||||
<th style="width:<%= 100/total_width %>%" class="closable ellipsible">
|
||||
<div style="float:right;position:relative;">
|
||||
<%= link_to '',
|
||||
toggle_exposure_measurement_routine_path(@routine, 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>
|
||||
<% extra_quantities = @measurements.values.first.keys - @quantities %>
|
||||
<% @measurements.each do |measurement, readouts| %>
|
||||
<% row_class = "measurement #{cycle('odd', 'even')}" %>
|
||||
<tr id="measurement-<%= measurement.id %>" class="primary <%= row_class %>">
|
||||
<td class="topleft unwrappable" style="cursor: pointer;"
|
||||
onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', '.measurement').toggle(); return false;">
|
||||
<span class="icon icon-bullet-closed"><%= format_datetime(measurement) %></span>
|
||||
</td>
|
||||
<% @quantities.each do |q| %>
|
||||
<td class="primary right ellipsible"><%= format_value(readouts[q]) %></td>
|
||||
<% end %>
|
||||
<td class="right shrunk unwrappable"><%= action_links(measurement) %></td>
|
||||
</tr>
|
||||
|
||||
<tr class="<%= row_class %>" style="display:none">
|
||||
<% if @quantities.length > 0
|
||||
rows = (readouts.length - 1) / @quantities.length + 1
|
||||
else
|
||||
rows = 1
|
||||
end %>
|
||||
<td rowspan="<%= rows %>" class="topleft unwrappable" style="cursor: pointer;"
|
||||
onclick="$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', '.measurement').toggle(); return false;">
|
||||
<span class="icon icon-bullet-open"><%= format_datetime(measurement) %></span>
|
||||
</td>
|
||||
<% @quantities.each do |q| %>
|
||||
<td class="primary topleft ellipsible">
|
||||
<%= q.name %>
|
||||
<p class="right"><%= format_value(readouts[q]) %></p>
|
||||
</td>
|
||||
<% end %>
|
||||
<td rowspan="<%= rows %>" class="right shrunk unwrappable">
|
||||
<%= action_links(measurement) %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% next if @quantities.empty? %>
|
||||
<% extra_quantities.each_slice(@quantities.length) do |eqs| %>
|
||||
<tr class="extra <%= row_class %>" style="display:none">
|
||||
<% eqs.each do |q| %>
|
||||
<td class="extra topleft ellipsible">
|
||||
<%= q.name if readouts[q] %>
|
||||
<p class="right"><%= format_value(readouts[q]) %></p>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if @quantities.length > eqs.length %>
|
||||
<td class="space" colspan="<%= @quantities.length - eqs.length %>"></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
@@ -1,12 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= render partial: 'measurements/contextual' %>
|
||||
</div>
|
||||
|
||||
<div id="new-measurement">
|
||||
</div>
|
||||
|
||||
<%= title [t("measurements.index.heading"), project_measurements_path(@project)],
|
||||
@routine.name %>
|
||||
<div id='readouts'>
|
||||
<%= render partial: 'measurements/readouts' %>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
$('#readouts').html('<%= j render partial: 'measurements/readouts' %>');
|
||||
Reference in New Issue
Block a user