mirror of
https://github.com/docusealco/docuseal
synced 2026-11-05 14:42:33 -05:00
update document name on clone
This commit is contained in:
1 parent
f380200e03
commit
d3033c072a
2 files changed
+10
-7
No files matched your search
@@ -12,7 +12,13 @@ module Templates
|
||||
template.preferences = original_template.preferences.deep_dup
|
||||
template.name = name.presence || "#{original_template.name} (#{I18n.t('clone')})"
|
||||
|
||||
template.assign_attributes(original_template.slice(:folder_id, :schema))
|
||||
template.assign_attributes(original_template.slice(:folder_id, :schema).deep_dup)
|
||||
|
||||
if name.present? && template.schema.size == 1 &&
|
||||
original_template.schema.first['name'] == original_template.name &&
|
||||
template.name != "#{original_template.name} (#{I18n.t('clone')})"
|
||||
template.schema.first['name'] = template.name
|
||||
end
|
||||
|
||||
template.folder = TemplateFolders.find_or_create_by_name(author, folder_name) if folder_name.present?
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@ module Templates
|
||||
def call(template:, original_template:, documents: [])
|
||||
schema_uuids_replacements = {}
|
||||
|
||||
cloned_schema = original_template.schema.deep_dup
|
||||
cloned_fields = template.fields.deep_dup
|
||||
|
||||
cloned_schema.each_with_index do |schema_item, index|
|
||||
template.schema.each_with_index do |schema_item, index|
|
||||
new_schema_item_uuid = SecureRandom.uuid
|
||||
|
||||
schema_uuids_replacements[schema_item['attachment_uuid']] = new_schema_item_uuid
|
||||
@@ -21,7 +18,7 @@ module Templates
|
||||
schema_item['name'] = new_name if new_name.present?
|
||||
end
|
||||
|
||||
cloned_fields.each do |field|
|
||||
template.fields.each do |field|
|
||||
next if field['areas'].blank?
|
||||
|
||||
field['areas'].each do |area|
|
||||
@@ -29,7 +26,7 @@ module Templates
|
||||
end
|
||||
end
|
||||
|
||||
template.update!(schema: cloned_schema, fields: cloned_fields)
|
||||
template.save!
|
||||
|
||||
original_template.schema_documents.map do |document|
|
||||
new_document =
|
||||
|
||||
Reference in new issue
Block a user