forked from fixin.me/fixin.me
- Add _wide_table.html.erb partial (server-rendered pivot table) - Add load_measurements helper in controller to prepare @wide_groups and @wide_quantities for all mutating actions - Update index view to render the wide_table partial in #measurements-wide - Add/update create, destroy, update turbo_stream views to refresh the wide table atomically after each mutation - Remove buildWideTable() and editMeasurementWide() from application.js - Fix create.turbo_stream.erb condition (empty readouts are vacuously all persisted) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.4 KiB
Plaintext
42 lines
1.4 KiB
Plaintext
<table class="items-table">
|
|
<thead>
|
|
<tr>
|
|
<th><%= Readout.human_attribute_name(:taken_at) %></th>
|
|
<% wide_quantities.each do |q| %>
|
|
<th><%= q.name %></th>
|
|
<% end %>
|
|
<th><%= Readout.human_attribute_name(:created_at) %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% wide_groups.each do |taken_at, readouts| %>
|
|
<tr>
|
|
<td><%= l(taken_at) if taken_at %></td>
|
|
<% wide_quantities.each do |q| %>
|
|
<% readout = readouts.find { |r| r.quantity_id == q.id } %>
|
|
<td class="ralign">
|
|
<% if readout %>
|
|
<span class="wide-cell">
|
|
<% if current_user.at_least(:active) %>
|
|
<%= link_to format("%.10g", readout.value),
|
|
edit_measurement_path(readout, view: :wide),
|
|
class: 'link', onclick: 'this.blur();',
|
|
data: {turbo_stream: true} %>
|
|
<% else %>
|
|
<%= format("%.10g", readout.value) %>
|
|
<% end %>
|
|
<%= readout.unit.symbol %>
|
|
<% if current_user.at_least(:active) %>
|
|
<%= image_button_to '', 'delete-outline', measurement_path(readout),
|
|
method: :delete, data: {turbo_stream: true} %>
|
|
<% end %>
|
|
</span>
|
|
<% end %>
|
|
</td>
|
|
<% end %>
|
|
<td><%= l(readouts.first.created_at) %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|