|
|
|
@ -25,7 +25,7 @@ class TemplatesDashboardController < ApplicationController
|
|
|
|
@templates = @templates.none
|
|
|
|
@templates = @templates.none
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@template_folders = @template_folders.reject { |e| e.name == TemplateFolder::DEFAULT_NAME }
|
|
|
|
@template_folders = @template_folders.reject { |e| e.name == TemplateFolder::DEFAULT_NAME }
|
|
|
|
@templates = filter_templates(@templates)
|
|
|
|
@templates = filter_templates(@templates).preload(:author, :template_accesses)
|
|
|
|
@templates = Templates::Order.call(@templates, current_user, cookies.permanent[:dashboard_templates_order])
|
|
|
|
@templates = Templates::Order.call(@templates, current_user, cookies.permanent[:dashboard_templates_order])
|
|
|
|
|
|
|
|
|
|
|
|
limit =
|
|
|
|
limit =
|
|
|
|
@ -42,7 +42,7 @@ class TemplatesDashboardController < ApplicationController
|
|
|
|
private
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
|
|
def filter_templates(templates)
|
|
|
|
def filter_templates(templates)
|
|
|
|
rel = templates.active.preload(:author, :template_accesses)
|
|
|
|
rel = templates.active
|
|
|
|
|
|
|
|
|
|
|
|
if params[:q].blank?
|
|
|
|
if params[:q].blank?
|
|
|
|
if Docuseal.multitenant? ? current_account.testing? : current_account.linked_account_account
|
|
|
|
if Docuseal.multitenant? ? current_account.testing? : current_account.linked_account_account
|
|
|
|
@ -51,7 +51,14 @@ class TemplatesDashboardController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
shared_template_ids = TemplateSharing.where(account_id: shared_account_ids).select(:template_id)
|
|
|
|
shared_template_ids = TemplateSharing.where(account_id: shared_account_ids).select(:template_id)
|
|
|
|
|
|
|
|
|
|
|
|
rel = rel.where(folder_id: current_account.default_template_folder.id).or(rel.where(id: shared_template_ids))
|
|
|
|
rel = Template.where(
|
|
|
|
|
|
|
|
Template.arel_table[:id].in(
|
|
|
|
|
|
|
|
Arel::Nodes::Union.new(
|
|
|
|
|
|
|
|
rel.where(folder_id: current_account.default_template_folder.id).select(:id).arel,
|
|
|
|
|
|
|
|
shared_template_ids.arel
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rel = rel.where(folder_id: current_account.default_template_folder.id)
|
|
|
|
rel = rel.where(folder_id: current_account.default_template_folder.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|