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),
|
||||
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">⠿</td>
|
||||
|
||||
<td class="handle" draggable="true">⠿
|
||||
<% 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 %>
|
||||
<% @ancestors.each do |ancestor| %>
|
||||
<%= turbo_stream.replace ancestor %>
|
||||
|
||||
@@ -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,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' %>
|
||||
|
||||
@@ -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,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,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,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 %>
|
||||
|
||||
@@ -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,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 %>
|
||||
|
||||
@@ -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">⠿</td>
|
||||
<td class="handle" draggable="true">⠿
|
||||
<% else %>
|
||||
<td></td>
|
||||
<td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -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' %>
|
||||
|
||||
Reference in New Issue
Block a user