2024-03-23 23:33:42 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class TemplateFoldersAutocompleteController < ApplicationController
|
|
|
|
|
load_and_authorize_resource :template_folder, parent: false
|
|
|
|
|
|
|
|
|
|
LIMIT = 100
|
|
|
|
|
|
|
|
|
|
def index
|
2025-06-19 22:49:47 +03:00
|
|
|
templates_query = Template.accessible_by(current_ability).where(archived_at: nil)
|
|
|
|
|
|
|
|
|
|
template_folders = @template_folders.where(id: templates_query.select(:folder_id))
|
2024-03-23 23:33:42 +02:00
|
|
|
template_folders = TemplateFolders.search(template_folders, params[:q]).limit(LIMIT)
|
|
|
|
|
|
|
|
|
|
render json: template_folders.as_json(only: %i[name archived_at])
|
|
|
|
|
end
|
|
|
|
|
end
|