Files
docuseal/app/controllers/api/templates_controller.rb
T

33 lines
963 B
Ruby
Raw Normal View History

2023-05-31 23:19:20 +03:00
# frozen_string_literal: true
module Api
class TemplatesController < ApiBaseController
2023-09-17 00:45:57 +03:00
load_and_authorize_resource :template
2023-08-11 18:32:33 +03:00
2023-08-04 00:40:13 +03:00
def index
2023-09-17 00:45:57 +03:00
render json: @templates
2023-08-04 00:40:13 +03:00
end
2023-08-11 18:32:33 +03:00
def show
2023-08-12 12:34:02 +03:00
render json: @template.as_json(include: { author: { only: %i[id email first_name last_name] },
documents: { only: %i[id uuid], methods: %i[url filename] } })
2023-08-11 18:32:33 +03:00
end
2023-05-31 23:19:20 +03:00
2023-08-11 18:32:33 +03:00
def update
2023-05-31 23:19:20 +03:00
@template.update!(template_params)
render :ok
end
private
def template_params
params.require(:template).permit(:name,
schema: [%i[attachment_uuid name]],
2023-06-07 01:16:43 +03:00
submitters: [%i[name uuid]],
fields: [[:uuid, :submitter_uuid, :name, :type, :required,
2023-06-27 00:57:29 +03:00
{ options: [], areas: [%i[x y w h cell_w attachment_uuid page]] }]])
2023-05-31 23:19:20 +03:00
end
end
end