1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-10 07:55:21 +02:00

Add ability to delete all tags

This commit is contained in:
hatz 2025-05-02 19:51:06 -05:00
parent 441f436187
commit 1fb39f78ee
No known key found for this signature in database
3 changed files with 27 additions and 7 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

@ -1,13 +1,27 @@
<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>
<%= render LinkComponent.new( <div class="flex items-center gap-2">
text: t(".new"), <%= render MenuComponent.new do |menu| %>
variant: "primary", <% menu.with_item(
href: new_tag_path, variant: "button",
icon: "plus", text: "Delete all",
frame: :modal 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> </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