diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb
index 259521d0..1c6c3b4d 100644
--- a/app/controllers/submissions_controller.rb
+++ b/app/controllers/submissions_controller.rb
@@ -53,11 +53,22 @@ class SubmissionsController < ApplicationController
end
def destroy
- @submission.update!(archived_at: Time.current)
+ notice =
+ if params[:permanently].present?
+ @submission.destroy!
- SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id)
+ Rollbar.info("Remove submission: #{@submission.id}") if defined?(Rollbar)
- redirect_back(fallback_location: template_path(@submission.template), notice: 'Submission has been archived')
+ 'Submission has been removed'
+ else
+ @submission.update!(archived_at: Time.current)
+
+ SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id)
+
+ 'Submission has been archived'
+ end
+
+ redirect_back(fallback_location: template_path(@submission.template), notice:)
end
private
diff --git a/app/views/submissions_archived/index.html.erb b/app/views/submissions_archived/index.html.erb
index c21974af..75166fec 100644
--- a/app/views/submissions_archived/index.html.erb
+++ b/app/views/submissions_archived/index.html.erb
@@ -12,7 +12,7 @@
<% if @pagy.count > 0 %>
- <%= render partial: 'templates/submission', collection: @submissions, locals: { with_template: true } %>
+ <%= render partial: 'templates/submission', collection: @submissions, locals: { with_template: true, archived: true } %>
<% elsif params[:q].present? %>
diff --git a/app/views/templates/_submission.html.erb b/app/views/templates/_submission.html.erb
index 9b09eda8..31ee04fa 100644
--- a/app/views/templates/_submission.html.erb
+++ b/app/views/templates/_submission.html.erb
@@ -85,6 +85,11 @@
<%= button_to button_title(title: nil, disabled_with: 'Arch', icon: svg_icon('archive', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Archive', method: :delete, data: { turbo_confirm: 'Are you sure?' }, onclick: 'event.stopPropagation()' %>
<% end %>
+ <% if local_assigns[:archived] && can?(:destroy, submission) %>
+
+ <%= button_to button_title(title: nil, disabled_with: 'Rem', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission, permanently: true), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Remove', method: :delete, data: { turbo_confirm: 'Submission deletion is irreversible and will permanently remove all associated signed documents with it. Are you sure?' }, onclick: 'event.stopPropagation()' %>
+
+ <% end %>
<% else %>
diff --git a/app/views/templates_archived_submissions/index.html.erb b/app/views/templates_archived_submissions/index.html.erb
index 6d8ce7b8..f97ccde8 100644
--- a/app/views/templates_archived_submissions/index.html.erb
+++ b/app/views/templates_archived_submissions/index.html.erb
@@ -19,7 +19,7 @@
<% if @pagy.count > 0 %>
- <%= render partial: 'templates/submission', collection: @submissions, locals: { template: @template } %>
+ <%= render partial: 'templates/submission', collection: @submissions, locals: { template: @template, archived: true } %>
<% elsif params[:q].present? %>