diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 0794e1e7..1c286290 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -34,6 +34,11 @@ class TagsController < ApplicationController redirect_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 + private def set_tag diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index d12bd356..24bc2d10 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -1,13 +1,27 @@

<%= t(".tags") %>

- <%= render LinkComponent.new( - text: t(".new"), - variant: "primary", - href: new_tag_path, - icon: "plus", - frame: :modal - ) %> +
+ <%= 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 + ) %> + +
+
diff --git a/config/routes.rb b/config/routes.rb index b0538fb1..da7790fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,6 +64,7 @@ Rails.application.routes.draw do resources :tags, except: :show do resources :deletions, only: %i[new create], module: :tag + delete :destroy_all, on: :collection end namespace :category do