2023-09-22 02:20:38 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
module Api
|
|
|
|
|
class TemplateFoldersAutocompleteController < ApiBaseController
|
|
|
|
|
load_and_authorize_resource :template_folder, parent: false
|
|
|
|
|
|
|
|
|
|
LIMIT = 100
|
|
|
|
|
|
|
|
|
|
def index
|
2023-12-30 00:37:03 +02:00
|
|
|
template_folders = @template_folders.joins(:templates).where(templates: { archived_at: nil }).distinct
|
2023-09-22 02:20:38 +03:00
|
|
|
template_folders = TemplateFolders.search(template_folders, params[:q]).limit(LIMIT)
|
|
|
|
|
|
2023-12-30 00:37:03 +02:00
|
|
|
render json: template_folders.as_json(only: %i[name archived_at])
|
2023-09-22 02:20:38 +03:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|