add folders structure

This commit is contained in:
Alex Turchyn
2023-09-22 02:20:38 +03:00
parent f8712a9da9
commit 380f553a17
30 changed files with 405 additions and 56 deletions
@@ -0,0 +1,16 @@
# frozen_string_literal: true
module Api
class TemplateFoldersAutocompleteController < ApiBaseController
load_and_authorize_resource :template_folder, parent: false
LIMIT = 100
def index
template_folders = @template_folders.joins(:templates).where(templates: { deleted_at: nil }).distinct
template_folders = TemplateFolders.search(template_folders, params[:q]).limit(LIMIT)
render json: template_folders.as_json(only: %i[name deleted_at])
end
end
end