fixin.me/app/views/units/_unit.html.erb
cryptogopher 175ccf6eae Allow Unit rebase to top-level
Outline base Unit row during drag
Closes #25
2024-04-05 02:18:05 +02:00

32 lines
1.2 KiB
Plaintext

<%= 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)} do %>
<td class="<%= class_names('link', {subunit: unit.base}) %>">
<%= link_to unit.symbol, edit_unit_path(unit), id: dom_id(unit, :edit),
onclick: 'this.blur();', data: {turbo_stream: true} %>
</td>
<td><%= unit.name %></td>
<td class="number"><%= scientifize(unit.multiplier) %></td>
<% if current_user.at_least(:active) %>
<td class="actions">
<% if unit.base.nil? %>
<%= image_link_to t(".add_subunit"), "plus-outline", new_unit_path(unit),
id: dom_id(unit, :add), onclick: 'this.blur();',
data: {turbo_stream: true} %>
<% end %>
<%= image_button_to t(".delete_unit"), "delete-outline", unit_path(unit),
method: :delete %>
</td>
<% if unit.movable? %>
<td class="handle" draggable="true">&#x283F</td>
<% else %>
<td></td>
<% end %>
<% end %>
<% end %>