Replace patched #dom_id with #dom_target

This commit is contained in:
2026-10-17 04:57:26 +02:00
parent f1578fad75
commit 2c845f3528
14 changed files with 45 additions and 60 deletions
+13 -13
View File
@@ -1,24 +1,24 @@
<%= tag.tr id: dom_id(quantity),
ondragstart: "dragStart(event)", ondragend: "dragEnd(event)",
ondragover: "dragOver(event)", ondrop: "drop(event)",
ondragenter: "dragEnter(event)", ondragleave: "dragLeave(event)",
data: {drag_path: reparent_quantity_path(quantity), drop_id: dom_id(quantity),
drop_id_param: "quantity[parent_id]"} do %>
<tr id="<%= dom_target(quantity) %>"
ondragstart="dragStart(event)" ondragend="dragEnd(event)"
ondragover="dragOver(event)" ondrop="drop(event)"
ondragenter="dragEnter(event)" ondragleave="dragLeave(event)"
data-drag-path="<%= reparent_quantity_path(quantity) %>"
data-drop-id="<%= dom_target(quantity) %>"
data-drop-id-param="<%= field_name(:quantity, :parent_id) %>">
<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.description %>
<% 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_link_to t('.new_subquantity'), 'plus-outline',
new_quantity_path(quantity), id: dom_target(:new, quantity, :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">&#x283F</td>
<% end %>
<td class="handle" draggable="true">&#x283F
<% end %>
+1 -1
View File
@@ -1,4 +1,4 @@
<%= turbo_stream.close_form dom_id(@quantity.parent || Quantity, :new) %>
<%= turbo_stream.close_form dom_target(:new, @quantity.parent || :quantity) %>
<%= turbo_stream.remove :no_items %>
<% @ancestors.each do |ancestor| %>
<%= turbo_stream.replace ancestor %>
+3 -3
View File
@@ -1,7 +1,7 @@
<% ids = {row: dom_id(@quantity, :edit),
hidden_row: dom_id(@quantity),
<% ids = {row: dom_target(:edit, @quantity),
hidden_row: dom_target(@quantity),
link: nil,
form_tag: dom_id(@quantity, :edit, :form)} %>
form_tag: dom_target(:edit, @quantity, :form)} %>
<%= turbo_stream.append :quantity_form do %>
<%- tabular_form_with model: @quantity, html: {id: ids[:form_tag]} do %>
+1 -2
View File
@@ -1,8 +1,7 @@
<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} %>
id: :new_quantity_link, onclick: 'this.blur();', data: {turbo_stream: true} %>
<% end %>
<%#= image_link_to t('.import_quantities'), 'download-outline', default_quantities_path,
class: 'tools-area' %>
+4 -4
View File
@@ -1,8 +1,8 @@
<% dom_obj = @quantity.parent || @quantity %>
<% ids = {row: dom_id(dom_obj, :new),
<% target_id = dom_target(:new, @quantity.parent || :quantity) %>
<% ids = {row: target_id,
hidden_row: nil,
link: dom_id(dom_obj, :new, :link),
form_tag: dom_id(dom_obj, :new, :form)} %>
link: dom_target(target_id, :link),
form_tag: dom_target(target_id, :form)} %>
<%= turbo_stream.disable ids[:link] -%>
+1 -1
View File
@@ -1,4 +1,4 @@
<%= turbo_stream.close_form dom_id(@quantity, :edit) %>
<%= turbo_stream.close_form dom_target(:edit, @quantity) %>
<% @ancestors.push(@quantity).each do |ancestor| %>
<%= turbo_stream.replace ancestor %>
<% end %>
+1 -1
View File
@@ -1,6 +1,6 @@
<%# TODO: add readout reordering by dragging %>
<%= tabular_fields_for 'readouts[]', readout do |form| %>
<%- tag.tr id: dom_id(readout.quantity, :new, :readout) do %>
<%- tag.tr id: dom_target(:new, readout.quantity, :readout) do %>
<td>
<%# TODO: add grayed readout index (in separate column?) %>
<%= readout.quantity.relative_pathname(@superquantity) %>
+1 -1
View File
@@ -1,7 +1,7 @@
<%= turbo_stream.update(:measurement_form_legend) { @superquantity&.pathname } %>
<% @prev_quantities.each do |pq| %>
<%= turbo_stream.update dom_id(pq, nil, :pathname) do %>
<%= turbo_stream.update dom_target(pq, :pathname) do %>
<%= pq.relative_pathname(@superquantity) %>
<% end %>
<% end %>
+2 -2
View File
@@ -1,4 +1,4 @@
<%= turbo_stream.disable :create_measurement_button if @prev_quantities.one? %>
<%= turbo_stream.remove dom_id(@quantity, :new, :readout) %>
<%= turbo_stream.remove dom_target(:new, @quantity, :readout) %>
<%= render partial: 'form_repath' %>
<%= turbo_stream.unselect dom_id(@quantity) %>
<%= turbo_stream.unselect dom_target(@quantity) %>
+1 -1
View File
@@ -1,5 +1,5 @@
<% @readouts.each do |r| %>
<%= turbo_stream.disable dom_id(r.quantity) %>
<%= turbo_stream.disable dom_target(r.quantity) %>
<% end %>
<%= render partial: 'form_repath' %>
<%= turbo_stream.append :readouts do %>
+16 -16
View File
@@ -1,32 +1,32 @@
<%= tag.tr id: dom_id(unit),
ondragstart: "dragStart(event)", ondragend: "dragEnd(event)",
ondragover: "dragOver(event)", ondrop: "drop(event)",
ondragenter: "dragEnter(event)", ondragleave: "dragLeave(event)",
data: {drag_path: rebase_unit_path(unit),
drop_id: dom_id(unit.base || unit),
drop_id_param: "unit[base_id]"} do %>
<tr id="<%= dom_target(unit) %>"
ondragstart="dragStart(event)" ondragend="dragEnd(event)"
ondragover="dragOver(event)" ondrop="drop(event)"
ondragenter="dragEnter(event)" ondragleave="dragLeave(event)"
data-drag-path="<%= rebase_unit_path(unit) %>"
data-drop-id="<%= dom_target(unit.base || unit) %>"
data-drop-id-param="<%= field_name(:unit, :base_id) %>">
<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><%= unit.description %>
<%# Closing <td> tag required to avoid whitespace inclusion for testing. %>
<td class="ralign"><%= unit.multiplier.to_html if unit.base_id? %></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} %>
id: dom_target(:new, unit, :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>
<%= image_button_to_if unit.movable?, t('.destroy'), 'delete-outline',
unit_path(unit), method: :delete %>
<% if unit.movable? %>
<td class="handle" draggable="true">&#x283F</td>
<td class="handle" draggable="true">&#x283F
<% else %>
<td></td>
<% end %>
<td>
<% end %>
<% end %>
+1 -1
View File
@@ -1,7 +1,7 @@
<div class="rightside-area buttongrid">
<% if current_user.at_least(:active) %>
<%= image_link_to t('.new_unit'), 'plus-outline', new_unit_path,
id: dom_id(Unit, :new, :link), onclick: 'this.blur();', data: {turbo_stream: true} %>
id: :new_unit_link, onclick: 'this.blur();', data: {turbo_stream: true} %>
<% end %>
<%= image_link_to t('.import_units'), 'download-outline', default_units_path,
class: 'tools-area' %>
-4
View File
@@ -9,10 +9,6 @@ ActiveSupport.on_load :action_dispatch_system_test_case do
XPath::DSL.prepend CoreExt::XPath::DSL::NormalizeSpaceDefault
end
ActiveSupport.on_load :action_view do
ActionView::RecordIdentifier.prepend CoreExt::ActionView::RecordIdentifierWithSuffix
end
ActiveSupport.on_load :active_record do
ActiveModel::Validations::NumericalityValidator
.prepend CoreExt::ActiveModel::Validations::NumericalityValidatesPrecision
@@ -1,10 +0,0 @@
module CoreExt::ActionView::RecordIdentifierWithSuffix
# TODO: replace dom_id with dom_target, then remove this override
def dom_id(object, prefix = nil, suffix = nil)
if suffix
"#{super(object, prefix)}#{::ActionView::RecordIdentifier::JOIN}#{suffix}"
else
super(object, prefix)
end
end
end