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>
37 lines
1.4 KiB
Plaintext
37 lines
1.4 KiB
Plaintext
<div class="rightside-area buttongrid">
|
|
<% if current_user.at_least(:active) %>
|
|
<%= image_link_to t('.new_quantity'), 'plus-outline', new_quantity_path,
|
|
id: dom_id(Quantity, :new, :link), onclick: 'this.blur();',
|
|
data: {turbo_stream: true} %>
|
|
<% end %>
|
|
<%#= image_link_to t('.import_quantities'), 'download-outline', default_quantities_path,
|
|
class: 'tools-area' %>
|
|
</div>
|
|
|
|
<%# TODO: remove? form can be inserted directly, e.g. at the end of index %>
|
|
<%= tag.div class: 'main-area', id: :quantity_form %>
|
|
|
|
<table class="main-area items-table">
|
|
<thead>
|
|
<tr>
|
|
<th><%= Quantity.human_attribute_name(:name) %></th>
|
|
<th class="hexpand"><%= Quantity.human_attribute_name(:description) %></th>
|
|
<th><%= Quantity.human_attribute_name(:default_unit) %></th>
|
|
<% if current_user.at_least(:active) %>
|
|
<th><%= t :actions %></th>
|
|
<th></th>
|
|
<% end %>
|
|
</tr>
|
|
<%= tag.tr id: "quantity_", hidden: true,
|
|
data: {controller: 'drag',
|
|
action: 'dragover->drag#over drop->drag#drop dragenter->drag#enter dragleave->drag#leave',
|
|
drag_drop_id_value: 'quantity_',
|
|
drag_drop_id_param_value: 'quantity[parent_id]'} do %>
|
|
<th colspan="5"><%= t '.top_level_drop' %></th>
|
|
<% end %>
|
|
</thead>
|
|
<tbody id="quantities">
|
|
<%= render(@quantities) || render_no_items %>
|
|
</tbody>
|
|
</table>
|