diff --git a/app/views/icons/_rotate.html.erb b/app/views/icons/_rotate.html.erb
new file mode 100644
index 00000000..eff3a99f
--- /dev/null
+++ b/app/views/icons/_rotate.html.erb
@@ -0,0 +1,4 @@
+
diff --git a/app/views/shared/_pagination.html.erb b/app/views/shared/_pagination.html.erb
index d3ceb6dc..1a2771ae 100644
--- a/app/views/shared/_pagination.html.erb
+++ b/app/views/shared/_pagination.html.erb
@@ -3,6 +3,7 @@
<%= @pagy.from %>-<%= @pagy.to %> of <%= @pagy.count %> <%= local_assigns[:items_name] || 'items' %>
+ <%= local_assigns[:left_additional_html] %>
<% if @pagy.prev %>
diff --git a/app/views/templates/_submission.html.erb b/app/views/templates/_submission.html.erb
index 16dc6015..e9f402b5 100644
--- a/app/views/templates/_submission.html.erb
+++ b/app/views/templates/_submission.html.erb
@@ -38,7 +38,9 @@
<%= render 'shared/clipboard_copy', text: submit_form_url(slug: submitter.slug), class: 'btn btn-sm btn-neutral text-white md:w-36 flex', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy Link', copy_title_md: 'Copy', copied_title_md: 'Copied' %>
<% end %>
View
- <%= button_to button_title(title: nil, disabled_with: 'Remov', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' }, onclick: 'event.stopPropagation()' %>
+ <% unless submission.deleted_at? %>
+ <%= button_to button_title(title: nil, disabled_with: 'Remov', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' }, onclick: 'event.stopPropagation()' %>
+ <% end %>
<% else %>
@@ -110,7 +112,9 @@
<% end %>
View
- <%= button_to button_title(title: nil, disabled_with: 'Remov', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' }, onclick: 'event.stopPropagation()' %>
+ <% unless submission.deleted_at? %>
+ <%= button_to button_title(title: nil, disabled_with: 'Remov', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' }, onclick: 'event.stopPropagation()' %>
+ <% end %>
<% end %>
diff --git a/app/views/templates/_template.html.erb b/app/views/templates/_template.html.erb
new file mode 100644
index 00000000..1665f630
--- /dev/null
+++ b/app/views/templates/_template.html.erb
@@ -0,0 +1,38 @@
+
+
+
+ <%= template.name %>
+
+
+
+ <%= svg_icon('user', class: 'w-4 h-4') %>
+ <%= template.author.full_name.presence || template.author.email %>
+
+
+ <%= svg_icon('calendar', class: 'w-4 h-4') %>
+ <%= l(template.created_at.in_time_zone(current_account.timezone), format: :short, locale: current_account.locale) %>
+
+
+
+
+ <% if template.deleted_at? %>
+ <%= button_to template_restore_index_path(template), class: 'btn btn-xs hover:btn-outline bg-base-200 btn-circle' do %>
+ <%= svg_icon('rotate', class: 'w-4 h-4 enabled') %>
+ <%= svg_icon('loader', class: 'w-4 h-4 animate-spin disabled') %>
+ <% end %>
+ <% else %>
+
+ <%= svg_icon('pencil', class: 'w-4 h-4') %>
+
+ <% end %>
+
+ <%= svg_icon('copy', class: 'w-4 h-4') %>
+
+ <% unless template.deleted_at? %>
+ <%= 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 %>
+ <%= svg_icon('trash', class: 'w-4 h-4 enabled') %>
+ <%= svg_icon('loader', class: 'w-4 h-4 animate-spin disabled') %>
+ <% end %>
+ <% end %>
+
+
diff --git a/app/views/templates/_title.html.erb b/app/views/templates/_title.html.erb
new file mode 100644
index 00000000..286d6bc9
--- /dev/null
+++ b/app/views/templates/_title.html.erb
@@ -0,0 +1,28 @@
+
+
+ <%= template.name %>
+ <% if template.deleted_at? %>
+ Archived
+ <% end %>
+
+
+ <% unless template.deleted_at? %>
+ <%= button_to button_title(title: 'Remove', disabled_with: 'Removing', icon: svg_icon('trash', class: 'w-6 h-6')), template_path(template), class: 'btn btn-outline btn-sm', method: :delete, data: { turbo_confirm: 'Are you sure?' } %>
+ <% end %>
+ <%= link_to new_template_path(base_template_id: template.id), class: 'btn btn-outline btn-sm', data: { turbo_frame: :modal } do %>
+ <%= svg_icon('copy', class: 'w-6 h-6') %>
+ Clone
+ <% end %>
+ <% unless template.deleted_at? %>
+ <%= link_to edit_template_path(template), class: 'btn btn-outline btn-sm' do %>
+
+ <%= svg_icon('pencil', class: 'w-6 h-6') %>
+ Edit
+
+ <% end %>
+ <% end %>
+ <% if template.deleted_at? %>
+ <%= button_to button_title(title: 'Restore', disabled_with: 'Restoring', icon: svg_icon('rotate', class: 'w-6 h-6')), template_restore_index_path(template), class: 'btn btn-outline btn-sm' %>
+ <% end %>
+
+
diff --git a/app/views/templates/show.html.erb b/app/views/templates/show.html.erb
index c7d9dd2e..77e25e32 100644
--- a/app/views/templates/show.html.erb
+++ b/app/views/templates/show.html.erb
@@ -1,21 +1,4 @@
-
-
- <%= @template.name %>
-
-
- <%= button_to button_title(title: 'Remove', disabled_with: 'Removing', icon: svg_icon('trash', class: 'w-6 h-6')), template_path(@template), class: 'btn btn-outline btn-sm', method: :delete, data: { turbo_confirm: 'Are you sure?' } %>
- <%= link_to new_template_path(base_template_id: @template.id), class: 'btn btn-outline btn-sm', data: { turbo_frame: :modal } do %>
- <%= svg_icon('copy', class: 'w-6 h-6') %>
- Clone
- <% end %>
- <%= link_to edit_template_path(@template), class: 'btn btn-outline btn-sm' do %>
-
- <%= svg_icon('pencil', class: 'w-6 h-6') %>
- Edit
-
- <% end %>
-
-
+<%= render 'title', template: @template %>
<% if !@pagy.count.zero? || @template.submitters.to_a.size == 1 %>
Submissions
@@ -24,12 +7,12 @@
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
Export
<% end %>
- <% if @template.submitters.to_a.size == 1 %>
+ <% if @template.submitters.to_a.size == 1 && !@template.deleted_at? %>
<%= render 'shared/clipboard_copy', text: start_form_url(slug: @template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy Share Link', copied_title: 'Copied to Clipboard', copy_title_md: 'Copy', copied_title_md: 'Copied' %>
<% end %>
- <% unless @pagy.count.zero? %>
+ <% if !@pagy.count.zero? && !@template.deleted_at? %>
<%= link_to new_template_submission_path(@template), class: 'order-1 btn btn-primary text-base', data: { turbo_frame: 'modal' } do %>
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
Add Recipients
@@ -42,21 +25,36 @@
<%= render partial: 'submission', collection: @submissions %>
- <%= render 'shared/pagination', pagy: @pagy, items_name: 'submissions' %>
+ <% view_archived_html = capture do %>
+ <% if @template.submissions.where.not(deleted_at: nil).exists? && !@template.deleted_at? %>
+
+ <% end %>
+ <% end %>
+ <% if @pagy.pages > 1 %>
+ <%= render 'shared/pagination', pagy: @pagy, items_name: 'submissions', left_additional_html: view_archived_html %>
+ <% else %>
+
+ <%= view_archived_html %>
+
+ <% end %>
<% else %>
There are no Submissions
-
Send an invitation to fill and complete the form
-
- <%= link_to new_template_submission_path(@template), class: 'base-button mt-6', data: { turbo_frame: 'modal' } do %>
- <%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
-
Add Recipients
- <% end %>
- <%= link_to start_form_url(slug: @template.slug), class: 'white-button mt-6', target: '_blank', rel: 'noopener' do %>
- <%= svg_icon('writing', class: 'w-6 h-6') %>
-
Submit it Yourself
+ <% if @template.deleted_at.blank? %>
+
Send an invitation to fill and complete the form
+
+ <%= link_to new_template_submission_path(@template), class: 'base-button mt-6', data: { turbo_frame: 'modal' } do %>
+ <%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
+ Add Recipients
+ <% end %>
+ <%= link_to start_form_url(slug: @template.slug), class: 'white-button mt-6', target: '_blank', rel: 'noopener' do %>
+ <%= svg_icon('writing', class: 'w-6 h-6') %>
+ Submit it Yourself
+ <% end %>
<% end %>
diff --git a/app/views/templates_archived/index.html.erb b/app/views/templates_archived/index.html.erb
new file mode 100644
index 00000000..0d173208
--- /dev/null
+++ b/app/views/templates_archived/index.html.erb
@@ -0,0 +1,13 @@
+
+ <%= link_to root_path(@template) do %>
+ ←
+ Back to Active
+ <% end %>
+
+
+
Document Templates Archived
+
+
+ <%= render partial: 'templates/template', collection: @templates %>
+
+<%= render 'shared/pagination', pagy: @pagy, items_name: 'templates' %>
diff --git a/app/views/templates_archived_submissions/show.html.erb b/app/views/templates_archived_submissions/show.html.erb
new file mode 100644
index 00000000..31bae929
--- /dev/null
+++ b/app/views/templates_archived_submissions/show.html.erb
@@ -0,0 +1,20 @@
+<%= render 'templates/title', template: @template %>
+
+ <%= link_to template_path(@template) do %>
+ ←
+ Back to Active
+ <% end %>
+
+
+
Submissions Archived
+
+ <%= link_to new_template_submissions_export_path(@template), class: 'order-3 md:order-1 btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
+ <%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
+ Export
+ <% end %>
+
+
+
+ <%= render partial: 'templates/submission', collection: @submissions %>
+
+<%= render 'shared/pagination', pagy: @pagy, items_name: 'submissions' %>
diff --git a/config/routes.rb b/config/routes.rb
index 38b3c067..8535d769 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -48,7 +48,10 @@ Rails.application.routes.draw do
resources :submissions, only: %i[show destroy]
resources :console_redirect, only: %i[index]
resource :templates_upload, only: %i[create]
+ resources :templates_archived, only: %i[index], path: 'archived'
resources :templates, only: %i[new create edit show destroy] do
+ resources :restore, only: %i[create], controller: 'templates_restore'
+ resource :archived, only: %i[show], controller: 'templates_archived_submissions'
resources :submissions, only: %i[new create]
resources :submissions_export, only: %i[index new]
end
diff --git a/spec/system/template_spec.rb b/spec/system/template_spec.rb
index d95a1632..dd092a43 100644
--- a/spec/system/template_spec.rb
+++ b/spec/system/template_spec.rb
@@ -51,7 +51,6 @@ RSpec.describe 'Template' do
end.to change { Template.active.count }.by(-1)
expect(page).to have_content('Template has been archived')
- expect(page).to have_current_path(root_path, ignore_query: true)
end
it 'edits a template' do