1
0

Added readout count to index

This commit is contained in:
cryptogopher 2019-12-03 00:47:37 +01:00
parent f769fff930
commit e1daade54f
2 changed files with 6 additions and 3 deletions

View File

@ -77,6 +77,6 @@ class MeasurementsController < ApplicationController
end end
def prepare_measurements def prepare_measurements
@measurements = @project.measurements.includes(:source) @measurements = @project.measurements.includes(:source, :readouts)
end end
end end

View File

@ -13,7 +13,10 @@
<% next if m.new_record? %> <% next if m.new_record? %>
<tr id="measurement-<%= m.id %>" class="measurement <%= 'hidden' if m.hidden %>"> <tr id="measurement-<%= m.id %>" class="measurement <%= 'hidden' if m.hidden %>">
<td class="date"><%= m.taken_at.strftime("%F %R") %></td> <td class="date"><%= m.taken_at.strftime("%F %R") %></td>
<td class="name"><%= m.name %></td> <td class="name">
<%= m.name %>
<small><%= " (#{m.readouts.size} readouts)" %></small>
</td>
<td class="source"><%= m.source.name if m.source.present? %></td> <td class="source"><%= m.source.name if m.source.present? %></td>
<td class="action"> <td class="action">
<%= link_to l(:button_retake), retake_measurement_path(m), { <%= link_to l(:button_retake), retake_measurement_path(m), {
@ -31,7 +34,7 @@
((action_name == "edit") || ((action_name == "edit") ||
(action_name == "update" && @measurement.errors.present?)) %> (action_name == "update" && @measurement.errors.present?)) %>
<tr> <tr>
<td class="form" colspan="4"> <td class="form" colspan="5">
<div id="edit-measurement"> <div id="edit-measurement">
<%= labelled_form_for @measurement, <%= labelled_form_for @measurement,
url: measurement_path(@measurement), url: measurement_path(@measurement),