Workable draft prefill identity (no link or query help)

This commit is contained in:
simon lehericey 2023-09-07 10:03:17 +02:00
parent 6198de1f43
commit 4cbb8e91f2
9 changed files with 169 additions and 79 deletions

View file

@ -3,11 +3,12 @@
module DossierPrefillableConcern
extend ActiveSupport::Concern
def prefill!(champs_attributes)
return unless champs_attributes.any?
def prefill!(champs_attributes, identity_attributes)
return if champs_attributes.empty? && identity_attributes.empty?
attributes = { prefilled: true }
attributes[:champs_attributes] = champs_attributes.map { |h| h.merge(prefilled: true) }
attributes[:individual_attributes] = identity_attributes
assign_attributes(attributes)
save(validate: false)