forked from fixin.me/fixin.me
Add stimulus-rails gem and wire up 7 controllers: - measurements_view_controller: view toggle (compact/wide) via localStorage - measurements_controller: grouped rows MutationObserver - charts_controller: Plotly chart rendering - form_controller: keyboard shortcuts (Escape/Enter) and submit validation - details_controller: quantity picker state, focusout close, MutationObserver - readout_unit_controller: default unit button enable/disable + PATCH submission - drag_controller: drag-and-drop for quantity reparenting and unit rebasing Remove all inline onclick/onkeydown/ondrag*/onsubmit handlers from templates. Remove all window.* global exports from application.js. Remove bare <script> block from measurements/_form.html.erb. Remove turbo:load listeners for behavior now in controller connect(). application.js now only contains: Turbo Stream custom action definitions and the showPage visibility listener. Document Stimulus conventions in CLAUDE.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.8 KiB
Plaintext
42 lines
1.8 KiB
Plaintext
<%# TODO: show hint when no quantities/units defined %>
|
|
<div class="rightside-area buttongrid" data-controller="measurements-view">
|
|
<% if current_user.at_least(:active) %>
|
|
<%= image_link_to t('.new_measurement'), 'plus-outline', new_measurement_path,
|
|
id: :new_measurement_link, onclick: 'this.blur();',
|
|
data: {turbo_stream: true} %>
|
|
<% end %>
|
|
<%= image_button_tag '', 'view-rows', name: nil, type: 'button',
|
|
class: 'view-toggle', title: t('.view_compact'),
|
|
data: {view: 'compact', action: 'click->measurements-view#set',
|
|
'measurements-view-name-param': 'compact'} %>
|
|
<%= image_button_tag '', 'view-columns', name: nil, type: 'button',
|
|
class: 'view-toggle', title: t('.view_wide'),
|
|
data: {view: 'wide', action: 'click->measurements-view#set',
|
|
'measurements-view-name-param': 'wide'} %>
|
|
</div>
|
|
|
|
<div class="main-area measurements-section">
|
|
<%= tag.div id: :measurement_edit_form %>
|
|
<table class="items-table measurements-compact" data-controller="measurements">
|
|
<thead>
|
|
<tr>
|
|
<th><%= Quantity.model_name.human %></th>
|
|
<th><%= Readout.human_attribute_name(:value) %></th>
|
|
<th><%= Unit.model_name.human %></th>
|
|
<th data-column="taken-at"><%= Readout.human_attribute_name(:taken_at) %></th>
|
|
<th data-column="created-at"><%= Readout.human_attribute_name(:created_at) %></th>
|
|
<% if current_user.at_least(:active) %>
|
|
<th></th>
|
|
<% end %>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="measurements" data-measurements-target="tbody">
|
|
<%= render(partial: 'readout', collection: @measurements, as: :readout) || render_no_items %>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div id="measurements-wide" class="measurements-wide">
|
|
<%= render 'wide_table', wide_groups: @wide_groups, wide_quantities: @wide_quantities %>
|
|
</div>
|
|
</div>
|