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>
27 lines
1.2 KiB
Plaintext
27 lines
1.2 KiB
Plaintext
<%= tag.tr id: dom_id(quantity),
|
|
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: reparent_quantity_path(quantity),
|
|
drag_drop_id_value: dom_id(quantity),
|
|
drag_drop_id_param_value: 'quantity[parent_id]'} do %>
|
|
|
|
<td style="--depth:<%= quantity.depth %>">
|
|
<%= link_to quantity, edit_quantity_path(quantity), class: 'link',
|
|
onclick: 'this.blur();', data: {turbo_stream: true} %>
|
|
</td>
|
|
<td><%= quantity.description %></td>
|
|
<td><%= quantity.default_unit&.symbol %></td>
|
|
|
|
<% if current_user.at_least(:active) %>
|
|
<td class="flex">
|
|
<%= image_link_to t('.new_subquantity'), 'plus-outline', new_quantity_path(quantity),
|
|
id: dom_id(quantity, :new, :link), onclick: 'this.blur();', data: {turbo_stream: true} %>
|
|
|
|
<%= image_button_to_if quantity.destroyable?, t('.destroy'), 'delete-outline',
|
|
quantity_path(quantity), method: :delete %>
|
|
</td>
|
|
<td class="handle" draggable="true">⠿</td>
|
|
<% end %>
|
|
<% end %>
|