mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
# frozen_string_literal: true
|
|
|
|
class TemplatesArchivedController < ApplicationController
|
|
load_and_authorize_resource :template, parent: false
|
|
|
|
def index
|
|
@templates = @templates.where.not(archived_at: nil)
|
|
.preload(:author, :template_accesses, folder: :parent_folder)
|
|
.order(id: :desc)
|
|
|
|
@templates = Templates.search(current_user, @templates, params[:q])
|
|
|
|
@pagy, @templates = pagy_auto(@templates.select_for_list, limit: 12)
|
|
|
|
return unless params[:q].present? && @templates.blank?
|
|
|
|
@related_submissions_pagy, @related_submissions = load_related_submissions
|
|
end
|
|
|
|
private
|
|
|
|
def load_related_submissions
|
|
related_submissions =
|
|
Submission.accessible_by(current_ability)
|
|
.joins(:template)
|
|
.where.not(templates: { archived_at: nil })
|
|
.preload(:template_accesses, :created_by_user,
|
|
template: :author,
|
|
submitters: :start_form_submission_events)
|
|
|
|
related_submissions = Submissions.search(current_user, related_submissions, params[:q])
|
|
.order(id: :desc)
|
|
|
|
pagy_auto(related_submissions.select_for_list, limit: 5)
|
|
end
|
|
end
|