forked from fixin.me/fixin.me
Replace JS-generated wide table with ERB partial and Turbo Streams
- 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>
This commit is contained in:
13
app/views/measurements/create.turbo_stream.erb
Normal file
13
app/views/measurements/create.turbo_stream.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<% if @readouts.present? && @readouts.all?(&:persisted?) %>
|
||||
<%= turbo_stream.update :flashes %>
|
||||
<%= turbo_stream.remove :measurement_form %>
|
||||
<%= turbo_stream.enable :new_measurement_link %>
|
||||
<%= turbo_stream.remove :no_items %>
|
||||
<% @readouts.each do |readout| %>
|
||||
<%= turbo_stream.prepend :measurements, partial: 'readout', locals: {readout: readout} %>
|
||||
<% end %>
|
||||
<%= turbo_stream.update 'measurements-wide', partial: 'wide_table',
|
||||
locals: {wide_groups: @wide_groups, wide_quantities: @wide_quantities} %>
|
||||
<% else %>
|
||||
<%= turbo_stream.update :flashes %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user