Allow to drag all Quantities

This commit is contained in:
cryptogopher 2025-01-14 15:03:25 +01:00
parent 644d1f4b9a
commit 8524beefdc
2 changed files with 3 additions and 7 deletions

View File

@ -62,7 +62,7 @@ class Quantity < ApplicationRecord
name
end
def movable?
def destroyable?
subquantities.empty?
end

View File

@ -17,13 +17,9 @@
<%= 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_button_to_if quantity.movable?, t('.destroy'), 'delete-outline',
<%= image_button_to_if quantity.destroyable?, t('.destroy'), 'delete-outline',
quantity_path(quantity), method: :delete %>
</td>
<% if quantity.movable? %>
<td class="handle" draggable="true">&#x283F</td>
<% else %>
<td></td>
<% end %>
<td class="handle" draggable="true">&#x283F</td>
<% end %>
<% end %>