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.
cryptogopher 681c0279fb Measurement improvements
Added 'new' action.
Separated js views for new/create/edit.
Displaying taken_at in local time.
Fixed readout destruction on edit.
2019-12-06 21:48:06 +01:00

50 lines
1.7 KiB
Plaintext

<% if @measurements.any? { |m| m.persisted? } %>
<table class="list">
<thead>
<tr>
<th><%= l(:field_taken_at_date) %></th>
<th><%= l(:field_name) %></th>
<th><%= l(:field_source) %></th>
<th style="width:10%"><%= l(:field_action) %></th>
</tr>
</thead>
<tbody>
<% @measurements.each do |m| %>
<% next if m.new_record? %>
<tr id="measurement-<%= m.id %>" class="measurement <%= 'hidden' if m.hidden %>">
<td class="date"><%= m.taken_at.getlocal.strftime("%F %R") %></td>
<td class="name">
<div style="float:left;"><%= m.name %></div>
<div style="float:right;">
<small><%= " (#{pluralize(m.readouts.size, 'readout')})" %></small>
</div>
</td>
<td class="source"><%= m.source.name if m.source.present? %></td>
<td class="action">
<%= link_to l(:button_retake), retake_measurement_path(m), {
remote: true,
class: "icon icon-reload"
} %>
<%= link_to l(:button_edit), edit_measurement_path(m), {
remote: true,
class: "icon icon-edit"
} %>
<%= delete_link measurement_path(m), {remote: true, data: {}} %>
</td>
</tr>
<% if (m == @measurement) && @measurement.errors.present? %>
<tr>
<td class="form" colspan="5">
<div id="edit-measurement">
<%= render partial: 'measurements/edit_form' %>
</div>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>