rename to templates

This commit is contained in:
Alex Turchyn
2023-05-31 23:19:20 +03:00
parent 98fc9d964a
commit 4a303cb423
59 changed files with 248 additions and 264 deletions
-22
View File
@@ -1,22 +0,0 @@
# frozen_string_literal: true
module Api
class FlowsController < ApiBaseController
def update
@flow = current_account.flows.find(params[:id])
@flow.update!(flow_params)
render :ok
end
private
def flow_params
params.require(:flow).permit(:name,
schema: [%i[attachment_uuid name]],
fields: [[:uuid, :name, :type, :required,
{ options: [], areas: [%i[x y w h attachment_uuid page]] }]])
end
end
end
@@ -0,0 +1,22 @@
# frozen_string_literal: true
module Api
class TemplatesController < ApiBaseController
def update
@template = current_account.templates.find(params[:id])
@template.update!(template_params)
render :ok
end
private
def template_params
params.require(:template).permit(:name,
schema: [%i[attachment_uuid name]],
fields: [[:uuid, :name, :type, :required,
{ options: [], areas: [%i[x y w h attachment_uuid page]] }]])
end
end
end
@@ -1,17 +1,17 @@
# frozen_string_literal: true
module Api
class FlowsDocumentsController < ApiBaseController
class TemplatesDocumentsController < ApiBaseController
def create
@flow = current_account.flows.find(params[:flow_id])
@template = current_account.templates.find(params[:template_id])
documents =
params[:blobs].map do |blob|
blob = ActiveStorage::Blob.find_signed(blob[:signed_id])
document = @flow.documents.create!(blob:)
document = @template.documents.create!(blob:)
Flows::ProcessDocument.call(document)
Templates::ProcessDocument.call(document)
end
schema = documents.map do |doc|