diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index c1e2c99e..971a6ba2 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -57,9 +57,18 @@ class TemplatesController < ApplicationController end def destroy - @template.update!(deleted_at: Time.current) + notice = + if !Docuseal.multitenant? && params[:permanently].present? + @template.destroy! - redirect_back(fallback_location: root_path, notice: 'Template has been archived.') + 'Template has been removed.' + else + @template.update!(deleted_at: Time.current) + + 'Template has been archived.' + end + + redirect_back(fallback_location: root_path, notice:) end private diff --git a/app/views/templates/_template.html.erb b/app/views/templates/_template.html.erb index a75e0b13..5982a1d8 100644 --- a/app/views/templates/_template.html.erb +++ b/app/views/templates/_template.html.erb @@ -52,9 +52,9 @@ <% end %> - <% if !template.deleted_at? && can?(:destroy, template) %> - - <%= button_to template_path(template), data: { turbo_confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-xs hover:btn-outline bg-base-200 btn-circle', aria_label: 'Restore' do %> + <% if (!template.deleted_at? || !Docuseal.multitenant?) && can?(:destroy, template) %> + + <%= button_to template_path(template), data: { turbo_confirm: 'Are you sure?' }, params: { permanently: template.deleted_at? }.compact_blank, method: :delete, class: 'btn btn-xs hover:btn-outline bg-base-200 btn-circle', aria_label: 'Restore' do %> <%= svg_icon('trash', class: 'w-4 h-4 enabled') %> <%= svg_icon('loader', class: 'w-4 h-4 animate-spin disabled') %> <% end %>