From 8524beefdc1047b2b2cb73da7327e5a96c7e876c Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Tue, 14 Jan 2025 15:03:25 +0100 Subject: [PATCH] Allow to drag all Quantities --- app/models/quantity.rb | 2 +- app/views/quantities/_quantity.html.erb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/models/quantity.rb b/app/models/quantity.rb index ebb22dd..985c2bc 100644 --- a/app/models/quantity.rb +++ b/app/models/quantity.rb @@ -62,7 +62,7 @@ class Quantity < ApplicationRecord name end - def movable? + def destroyable? subquantities.empty? end diff --git a/app/views/quantities/_quantity.html.erb b/app/views/quantities/_quantity.html.erb index 1ee0efa..c5d5d89 100644 --- a/app/views/quantities/_quantity.html.erb +++ b/app/views/quantities/_quantity.html.erb @@ -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 %> - <% if quantity.movable? %> - ⠿ - <% else %> - - <% end %> + ⠿ <% end %> <% end %>