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>
33 lines
1.3 KiB
Plaintext
33 lines
1.3 KiB
Plaintext
<%= tag.tr id: dom_id(unit),
|
|
draggable: true,
|
|
data: {controller: 'drag',
|
|
action: 'dragstart->drag#start dragend->drag#end dragover->drag#over drop->drag#drop dragenter->drag#enter dragleave->drag#leave',
|
|
drag_drag_path_value: rebase_unit_path(unit),
|
|
drag_drop_id_value: dom_id(unit.base || unit),
|
|
drag_drop_id_param_value: 'unit[base_id]'} do %>
|
|
|
|
<td style="--depth:<%= unit.base_id? ? 1 : 0 %>">
|
|
<%= link_to unit, edit_unit_path(unit), class: 'link', onclick: 'this.blur();',
|
|
data: {turbo_stream: true} %>
|
|
</td>
|
|
<td><%= unit.description %></td>
|
|
<td class="ralign"><%= unit.multiplier.to_html %></td>
|
|
|
|
<% if current_user.at_least(:active) %>
|
|
<td class="flex">
|
|
<% unless unit.base_id? %>
|
|
<%= image_link_to t('.new_subunit'), 'plus-outline', new_unit_path(unit),
|
|
id: dom_id(unit, :new, :link), onclick: 'this.blur();', data: {turbo_stream: true} %>
|
|
<% end %>
|
|
|
|
<%= image_button_to_if unit.movable?, t('.destroy'), 'delete-outline', unit_path(unit),
|
|
method: :delete %>
|
|
</td>
|
|
<% if unit.movable? %>
|
|
<td class="handle" draggable="true">⠿</td>
|
|
<% else %>
|
|
<td></td>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|