fix refactor dropzone

This commit is contained in:
Pete Matsyburka
2025-05-09 00:01:50 +03:00
parent 97b8ac4444
commit 24fe2a1192
20 changed files with 330 additions and 302 deletions
+5 -1
View File
@@ -4,6 +4,7 @@ module Templates
module Clone
module_function
# rubocop:disable Metrics, Style/CombinableLoops
def call(original_template, author:, external_id: nil, name: nil, folder_name: nil)
template = original_template.account.templates.new
@@ -29,10 +30,13 @@ module Templates
template.schema.first['name'] = template.name
end
original_template.template_accesses.each do |template_access|
template.template_accesses.new(user_id: template_access.user_id)
end
template
end
# rubocop:disable Metrics, Style/CombinableLoops
def update_submitters_and_fields_and_schema(cloned_submitters, cloned_fields, cloned_schema, cloned_preferences)
submitter_uuids_replacements = {}
field_uuids_replacements = {}
+1 -1
View File
@@ -27,7 +27,7 @@ module Templates
end
next if template.fields.any? { |f| f['areas']&.any? { |a| a['attachment_uuid'] == document.uuid } }
next unless submitter && document.metadata.dig('pdf', 'fields').present?
next if submitter.blank? || document.metadata.dig('pdf', 'fields').blank?
pdf_fields = document.metadata['pdf'].delete('fields').to_a
pdf_fields.each { |f| f['submitter_uuid'] = submitter['uuid'] }