The personal finance app for everyone
Add ability to delete all tags (#2200)
Alex Hatzenbuhlerc022e862aa44
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rbindex 0794e1e7..1c286290 100644--- a/app/controllers/tags_controller.rb+++ b/app/controllers/tags_controller.rb@@ -34,6 +34,11 @@ class TagsController < ApplicationControllerredirect_to tags_path, notice: t(".deleted")end+ def destroy_all+ Current.family.tags.destroy_all+ redirect_back_or_to tags_path, notice: "All tags deleted"+ end+privatedef set_tagdiff --git a/app/helpers/custom_confirm.rb b/app/helpers/custom_confirm.rbindex bf40f449..cdf24585 100644--- a/app/helpers/custom_confirm.rb+++ b/app/helpers/custom_confirm.rb@@ -6,9 +6,9 @@ class CustomConfirmnew(destructive: true,high_severity: high_severity,- title: "Delete #{resource_name}?",- body: "Are you sure you want to delete #{resource_name}? This is not reversible.",- btn_text: "Delete #{resource_name}"+ title: "Delete #{resource_name.titleize}?",+ body: "Are you sure you want to delete #{resource_name.downcase}? This is not reversible.",+ btn_text: "Delete #{resource_name.titleize}")endenddiff --git a/app/views/accounts/show/_menu.html.erb b/app/views/accounts/show/_menu.html.erbindex 5e59c88a..56d78f62 100644--- a/app/views/accounts/show/_menu.html.erb+++ b/app/views/accounts/show/_menu.html.erb@@ -19,7 +19,7 @@href: account_path(account),method: :delete,icon: "trash-2",- confirm: CustomConfirm.for_resource_deletion("Account", high_severity: true),+ confirm: CustomConfirm.for_resource_deletion("account", high_severity: true),data: { turbo_frame: :_top }) %><% end %>diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erbindex 95344043..5f630e74 100644--- a/app/views/categories/index.html.erb+++ b/app/views/categories/index.html.erb@@ -9,7 +9,7 @@href: destroy_all_categories_path,method: :delete,icon: "trash-2",- confirm: CustomConfirm.for_resource_deletion("All categories", high_severity: true)) %>+ confirm: CustomConfirm.for_resource_deletion("all categories", high_severity: true)) %><% end %><%= render LinkComponent.new(diff --git a/app/views/chats/_chat.html.erb b/app/views/chats/_chat.html.erbindex 79e02b73..fd904de1 100644--- a/app/views/chats/_chat.html.erb+++ b/app/views/chats/_chat.html.erb@@ -17,6 +17,6 @@href: chat_path(chat),icon: "trash-2",method: :delete,- confirm: CustomConfirm.for_resource_deletion("Chat")) %>+ confirm: CustomConfirm.for_resource_deletion("chat")) %><% end %><% end %>diff --git a/app/views/chats/_chat_nav.html.erb b/app/views/chats/_chat_nav.html.erbindex 47e56c8e..9faa2e5a 100644--- a/app/views/chats/_chat_nav.html.erb+++ b/app/views/chats/_chat_nav.html.erb@@ -29,7 +29,7 @@href: chat_path(chat),icon: "trash-2",method: :delete,- confirm: CustomConfirm.for_resource_deletion("Chat")) %>+ confirm: CustomConfirm.for_resource_deletion("chat")) %><% end %><% end %></nav>diff --git a/app/views/imports/_import.html.erb b/app/views/imports/_import.html.erbindex fca4764b..a0b1d965 100644--- a/app/views/imports/_import.html.erb+++ b/app/views/imports/_import.html.erb@@ -59,7 +59,7 @@href: import_path(import),icon: "trash-2",method: :delete,- confirm: CustomConfirm.for_resource_deletion("Import")) %>+ confirm: CustomConfirm.for_resource_deletion("import")) %><% end %><% end %></div>diff --git a/app/views/rules/_rule.html.erb b/app/views/rules/_rule.html.erbindex 0a19d9b3..e2b01b74 100644--- a/app/views/rules/_rule.html.erb+++ b/app/views/rules/_rule.html.erb@@ -55,7 +55,7 @@href: rule_path(rule),icon: "trash-2",method: :delete,- confirm: CustomConfirm.for_resource_deletion("Rule")) %>+ confirm: CustomConfirm.for_resource_deletion("rule")) %><% end %></div></div>diff --git a/app/views/rules/index.html.erb b/app/views/rules/index.html.erbindex 13e538b4..2c3040a1 100644--- a/app/views/rules/index.html.erb+++ b/app/views/rules/index.html.erb@@ -10,7 +10,7 @@href: destroy_all_rules_path,icon: "trash-2",method: :delete,- confirm: CustomConfirm.for_resource_deletion("All rules", high_severity: true)) %>+ confirm: CustomConfirm.for_resource_deletion("all rules", high_severity: true)) %><% end %><% end %>diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erbindex d12bd356..24bc2d10 100644--- a/app/views/tags/index.html.erb+++ b/app/views/tags/index.html.erb@@ -1,13 +1,27 @@<header class="flex items-center justify-between"><h1 class="text-primary text-xl font-medium"><%= t(".tags") %></h1>- <%= render LinkComponent.new(- text: t(".new"),- variant: "primary",- href: new_tag_path,- icon: "plus",- frame: :modal- ) %>+<div class="flex items-center gap-2">+ <%= render MenuComponent.new do |menu| %>+ <% menu.with_item(+ variant: "button",+ text: "Delete all",+ href: destroy_all_tags_path,+ method: :delete,+ icon: "trash-2",+ confirm: CustomConfirm.for_resource_deletion("all tags", high_severity: true)) %>+ <% end %>++ <%= render LinkComponent.new(+ text: t(".new"),+ variant: "primary",+ href: new_tag_path,+ icon: "plus",+ frame: :modal+ ) %>++</div>+</header><div class="bg-container shadow-border-xs rounded-xl p-4">diff --git a/config/routes.rb b/config/routes.rbindex b0538fb1..da7790fb 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -64,6 +64,7 @@ Rails.application.routes.draw doresources :tags, except: :show doresources :deletions, only: %i[new create], module: :tag+ delete :destroy_all, on: :collectionendnamespace :category do