forked from fixin.me/fixin.me
Replace patched #dom_id with #dom_target
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
<%= tag.tr id: dom_id(quantity),
|
<tr id="<%= dom_target(quantity) %>"
|
||||||
ondragstart: "dragStart(event)", ondragend: "dragEnd(event)",
|
ondragstart="dragStart(event)" ondragend="dragEnd(event)"
|
||||||
ondragover: "dragOver(event)", ondrop: "drop(event)",
|
ondragover="dragOver(event)" ondrop="drop(event)"
|
||||||
ondragenter: "dragEnter(event)", ondragleave: "dragLeave(event)",
|
ondragenter="dragEnter(event)" ondragleave="dragLeave(event)"
|
||||||
data: {drag_path: reparent_quantity_path(quantity), drop_id: dom_id(quantity),
|
data-drag-path="<%= reparent_quantity_path(quantity) %>"
|
||||||
drop_id_param: "quantity[parent_id]"} do %>
|
data-drop-id="<%= dom_target(quantity) %>"
|
||||||
|
data-drop-id-param="<%= field_name(:quantity, :parent_id) %>">
|
||||||
|
|
||||||
<td style="--depth:<%= quantity.depth %>">
|
<td style="--depth:<%= quantity.depth %>">
|
||||||
<%= link_to quantity, edit_quantity_path(quantity), class: 'link',
|
<%= link_to quantity, edit_quantity_path(quantity), class: 'link',
|
||||||
onclick: 'this.blur();', data: {turbo_stream: true} %>
|
onclick: 'this.blur();', data: {turbo_stream: true} %>
|
||||||
</td>
|
<td><%= quantity.description %>
|
||||||
<td><%= quantity.description %></td>
|
|
||||||
|
|
||||||
<% if current_user.at_least(:active) %>
|
<% if current_user.at_least(:active) %>
|
||||||
<td class="flex">
|
<td class="flex">
|
||||||
<%= image_link_to t('.new_subquantity'), 'plus-outline', new_quantity_path(quantity),
|
<%= image_link_to t('.new_subquantity'), 'plus-outline',
|
||||||
id: dom_id(quantity, :new, :link), onclick: 'this.blur();', data: {turbo_stream: true} %>
|
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',
|
<%= image_button_to_if quantity.destroyable?, t('.destroy'), 'delete-outline',
|
||||||
quantity_path(quantity), method: :delete %>
|
quantity_path(quantity), method: :delete %>
|
||||||
</td>
|
|
||||||
<td class="handle" draggable="true">⠿</td>
|
<td class="handle" draggable="true">⠿
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -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 %>
|
<%= turbo_stream.remove :no_items %>
|
||||||
<% @ancestors.each do |ancestor| %>
|
<% @ancestors.each do |ancestor| %>
|
||||||
<%= turbo_stream.replace ancestor %>
|
<%= turbo_stream.replace ancestor %>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<% ids = {row: dom_id(@quantity, :edit),
|
<% ids = {row: dom_target(:edit, @quantity),
|
||||||
hidden_row: dom_id(@quantity),
|
hidden_row: dom_target(@quantity),
|
||||||
link: nil,
|
link: nil,
|
||||||
form_tag: dom_id(@quantity, :edit, :form)} %>
|
form_tag: dom_target(:edit, @quantity, :form)} %>
|
||||||
|
|
||||||
<%= turbo_stream.append :quantity_form do %>
|
<%= turbo_stream.append :quantity_form do %>
|
||||||
<%- tabular_form_with model: @quantity, html: {id: ids[:form_tag]} do %>
|
<%- tabular_form_with model: @quantity, html: {id: ids[:form_tag]} do %>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<div class="rightside-area buttongrid">
|
<div class="rightside-area buttongrid">
|
||||||
<% if current_user.at_least(:active) %>
|
<% if current_user.at_least(:active) %>
|
||||||
<%= image_link_to t('.new_quantity'), 'plus-outline', new_quantity_path,
|
<%= image_link_to t('.new_quantity'), 'plus-outline', new_quantity_path,
|
||||||
id: dom_id(Quantity, :new, :link), onclick: 'this.blur();',
|
id: :new_quantity_link, onclick: 'this.blur();', data: {turbo_stream: true} %>
|
||||||
data: {turbo_stream: true} %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<%#= image_link_to t('.import_quantities'), 'download-outline', default_quantities_path,
|
<%#= image_link_to t('.import_quantities'), 'download-outline', default_quantities_path,
|
||||||
class: 'tools-area' %>
|
class: 'tools-area' %>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<% dom_obj = @quantity.parent || @quantity %>
|
<% target_id = dom_target(:new, @quantity.parent || :quantity) %>
|
||||||
<% ids = {row: dom_id(dom_obj, :new),
|
<% ids = {row: target_id,
|
||||||
hidden_row: nil,
|
hidden_row: nil,
|
||||||
link: dom_id(dom_obj, :new, :link),
|
link: dom_target(target_id, :link),
|
||||||
form_tag: dom_id(dom_obj, :new, :form)} %>
|
form_tag: dom_target(target_id, :form)} %>
|
||||||
|
|
||||||
<%= turbo_stream.disable ids[:link] -%>
|
<%= turbo_stream.disable ids[:link] -%>
|
||||||
|
|
||||||
|
|||||||
@@ -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| %>
|
<% @ancestors.push(@quantity).each do |ancestor| %>
|
||||||
<%= turbo_stream.replace ancestor %>
|
<%= turbo_stream.replace ancestor %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%# TODO: add readout reordering by dragging %>
|
<%# TODO: add readout reordering by dragging %>
|
||||||
<%= tabular_fields_for 'readouts[]', readout do |form| %>
|
<%= 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>
|
<td>
|
||||||
<%# TODO: add grayed readout index (in separate column?) %>
|
<%# TODO: add grayed readout index (in separate column?) %>
|
||||||
<%= readout.quantity.relative_pathname(@superquantity) %>
|
<%= readout.quantity.relative_pathname(@superquantity) %>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<%= turbo_stream.update(:measurement_form_legend) { @superquantity&.pathname } %>
|
<%= turbo_stream.update(:measurement_form_legend) { @superquantity&.pathname } %>
|
||||||
|
|
||||||
<% @prev_quantities.each do |pq| %>
|
<% @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) %>
|
<%= pq.relative_pathname(@superquantity) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= turbo_stream.disable :create_measurement_button if @prev_quantities.one? %>
|
<%= 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' %>
|
<%= render partial: 'form_repath' %>
|
||||||
<%= turbo_stream.unselect dom_id(@quantity) %>
|
<%= turbo_stream.unselect dom_target(@quantity) %>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<% @readouts.each do |r| %>
|
<% @readouts.each do |r| %>
|
||||||
<%= turbo_stream.disable dom_id(r.quantity) %>
|
<%= turbo_stream.disable dom_target(r.quantity) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= render partial: 'form_repath' %>
|
<%= render partial: 'form_repath' %>
|
||||||
<%= turbo_stream.append :readouts do %>
|
<%= turbo_stream.append :readouts do %>
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
<%= tag.tr id: dom_id(unit),
|
<tr id="<%= dom_target(unit) %>"
|
||||||
ondragstart: "dragStart(event)", ondragend: "dragEnd(event)",
|
ondragstart="dragStart(event)" ondragend="dragEnd(event)"
|
||||||
ondragover: "dragOver(event)", ondrop: "drop(event)",
|
ondragover="dragOver(event)" ondrop="drop(event)"
|
||||||
ondragenter: "dragEnter(event)", ondragleave: "dragLeave(event)",
|
ondragenter="dragEnter(event)" ondragleave="dragLeave(event)"
|
||||||
data: {drag_path: rebase_unit_path(unit),
|
data-drag-path="<%= rebase_unit_path(unit) %>"
|
||||||
drop_id: dom_id(unit.base || unit),
|
data-drop-id="<%= dom_target(unit.base || unit) %>"
|
||||||
drop_id_param: "unit[base_id]"} do %>
|
data-drop-id-param="<%= field_name(:unit, :base_id) %>">
|
||||||
|
|
||||||
<td style="--depth:<%= unit.base_id? ? 1 : 0 %>">
|
<td style="--depth:<%= unit.base_id? ? 1 : 0 %>">
|
||||||
<%= link_to unit, edit_unit_path(unit), class: 'link', onclick: 'this.blur();',
|
<%= link_to unit, edit_unit_path(unit), class: 'link', onclick: 'this.blur();',
|
||||||
data: {turbo_stream: true} %>
|
data: {turbo_stream: true} %>
|
||||||
</td>
|
<td><%= unit.description %>
|
||||||
<td><%= unit.description %></td>
|
<%# Closing <td> tag required to avoid whitespace inclusion for testing. %>
|
||||||
<td class="ralign"><%= unit.multiplier.to_html if unit.base_id? %></td>
|
<td class="ralign"><%= unit.multiplier.to_html if unit.base_id? %></td>
|
||||||
|
|
||||||
<% if current_user.at_least(:active) %>
|
<% if current_user.at_least(:active) %>
|
||||||
<td class="flex">
|
<td class="flex">
|
||||||
<% unless unit.base_id? %>
|
<% unless unit.base_id? %>
|
||||||
<%= image_link_to t('.new_subunit'), 'plus-outline', new_unit_path(unit),
|
<%= 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 %>
|
<% end %>
|
||||||
|
|
||||||
<%= image_button_to_if unit.movable?, t('.destroy'), 'delete-outline', unit_path(unit),
|
<%= image_button_to_if unit.movable?, t('.destroy'), 'delete-outline',
|
||||||
method: :delete %>
|
unit_path(unit), method: :delete %>
|
||||||
</td>
|
|
||||||
<% if unit.movable? %>
|
<% if unit.movable? %>
|
||||||
<td class="handle" draggable="true">⠿</td>
|
<td class="handle" draggable="true">⠿
|
||||||
<% else %>
|
<% else %>
|
||||||
<td></td>
|
<td>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="rightside-area buttongrid">
|
<div class="rightside-area buttongrid">
|
||||||
<% if current_user.at_least(:active) %>
|
<% if current_user.at_least(:active) %>
|
||||||
<%= image_link_to t('.new_unit'), 'plus-outline', new_unit_path,
|
<%= 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 %>
|
<% end %>
|
||||||
<%= image_link_to t('.import_units'), 'download-outline', default_units_path,
|
<%= image_link_to t('.import_units'), 'download-outline', default_units_path,
|
||||||
class: 'tools-area' %>
|
class: 'tools-area' %>
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ ActiveSupport.on_load :action_dispatch_system_test_case do
|
|||||||
XPath::DSL.prepend CoreExt::XPath::DSL::NormalizeSpaceDefault
|
XPath::DSL.prepend CoreExt::XPath::DSL::NormalizeSpaceDefault
|
||||||
end
|
end
|
||||||
|
|
||||||
ActiveSupport.on_load :action_view do
|
|
||||||
ActionView::RecordIdentifier.prepend CoreExt::ActionView::RecordIdentifierWithSuffix
|
|
||||||
end
|
|
||||||
|
|
||||||
ActiveSupport.on_load :active_record do
|
ActiveSupport.on_load :active_record do
|
||||||
ActiveModel::Validations::NumericalityValidator
|
ActiveModel::Validations::NumericalityValidator
|
||||||
.prepend CoreExt::ActiveModel::Validations::NumericalityValidatesPrecision
|
.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
|
|
||||||
Reference in New Issue
Block a user