1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-22 22:59:39 +02:00

Add ability to delete all tags (#2200)

* Add ability to delete all tags

* Downcase resource for confirmation

* Clean up deletion resource names

* titleize button
This commit is contained in:
Alex Hatzenbuhler 2025-05-05 11:43:46 -05:00 committed by GitHub
parent dcc43cb253
commit c022e862aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 37 additions and 17 deletions

View file

@ -34,6 +34,11 @@ class TagsController < ApplicationController
redirect_to tags_path, notice: t(".deleted") redirect_to tags_path, notice: t(".deleted")
end end
def destroy_all
Current.family.tags.destroy_all
redirect_back_or_to tags_path, notice: "All tags deleted"
end
private private
def set_tag def set_tag

View file

@ -6,9 +6,9 @@ class CustomConfirm
new( new(
destructive: true, destructive: true,
high_severity: high_severity, high_severity: high_severity,
title: "Delete #{resource_name}?", title: "Delete #{resource_name.titleize}?",
body: "Are you sure you want to delete #{resource_name}? This is not reversible.", body: "Are you sure you want to delete #{resource_name.downcase}? This is not reversible.",
btn_text: "Delete #{resource_name}" btn_text: "Delete #{resource_name.titleize}"
) )
end end
end end

View file

@ -19,7 +19,7 @@
href: account_path(account), href: account_path(account),
method: :delete, method: :delete,
icon: "trash-2", 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 } data: { turbo_frame: :_top }
) %> ) %>
<% end %> <% end %>

View file

@ -9,7 +9,7 @@
href: destroy_all_categories_path, href: destroy_all_categories_path,
method: :delete, method: :delete,
icon: "trash-2", icon: "trash-2",
confirm: CustomConfirm.for_resource_deletion("All categories", high_severity: true)) %> confirm: CustomConfirm.for_resource_deletion("all categories", high_severity: true)) %>
<% end %> <% end %>
<%= render LinkComponent.new( <%= render LinkComponent.new(

View file

@ -17,6 +17,6 @@
href: chat_path(chat), href: chat_path(chat),
icon: "trash-2", icon: "trash-2",
method: :delete, method: :delete,
confirm: CustomConfirm.for_resource_deletion("Chat")) %> confirm: CustomConfirm.for_resource_deletion("chat")) %>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -29,7 +29,7 @@
href: chat_path(chat), href: chat_path(chat),
icon: "trash-2", icon: "trash-2",
method: :delete, method: :delete,
confirm: CustomConfirm.for_resource_deletion("Chat")) %> confirm: CustomConfirm.for_resource_deletion("chat")) %>
<% end %> <% end %>
<% end %> <% end %>
</nav> </nav>

View file

@ -59,7 +59,7 @@
href: import_path(import), href: import_path(import),
icon: "trash-2", icon: "trash-2",
method: :delete, method: :delete,
confirm: CustomConfirm.for_resource_deletion("Import")) %> confirm: CustomConfirm.for_resource_deletion("import")) %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

View file

@ -55,7 +55,7 @@
href: rule_path(rule), href: rule_path(rule),
icon: "trash-2", icon: "trash-2",
method: :delete, method: :delete,
confirm: CustomConfirm.for_resource_deletion("Rule")) %> confirm: CustomConfirm.for_resource_deletion("rule")) %>
<% end %> <% end %>
</div> </div>
</div> </div>

View file

@ -10,7 +10,7 @@
href: destroy_all_rules_path, href: destroy_all_rules_path,
icon: "trash-2", icon: "trash-2",
method: :delete, method: :delete,
confirm: CustomConfirm.for_resource_deletion("All rules", high_severity: true)) %> confirm: CustomConfirm.for_resource_deletion("all rules", high_severity: true)) %>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -1,6 +1,17 @@
<header class="flex items-center justify-between"> <header class="flex items-center justify-between">
<h1 class="text-primary text-xl font-medium"><%= t(".tags") %></h1> <h1 class="text-primary text-xl font-medium"><%= t(".tags") %></h1>
<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( <%= render LinkComponent.new(
text: t(".new"), text: t(".new"),
variant: "primary", variant: "primary",
@ -8,6 +19,9 @@
icon: "plus", icon: "plus",
frame: :modal frame: :modal
) %> ) %>
</div>
</header> </header>
<div class="bg-container shadow-border-xs rounded-xl p-4"> <div class="bg-container shadow-border-xs rounded-xl p-4">

View file

@ -64,6 +64,7 @@ Rails.application.routes.draw do
resources :tags, except: :show do resources :tags, except: :show do
resources :deletions, only: %i[new create], module: :tag resources :deletions, only: %i[new create], module: :tag
delete :destroy_all, on: :collection
end end
namespace :category do namespace :category do