fix(dossier): safely remove child champs in apply_diff
This commit is contained in:
parent
94b4c8f46e
commit
72e27eb7b4
1 changed files with 7 additions and 6 deletions
|
@ -167,11 +167,12 @@ module DossierCloneConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
champs_to_remove += diff[:removed]
|
champs_to_remove += diff[:removed]
|
||||||
champs_to_remove
|
children_champs_to_remove, root_champs_to_remove = champs_to_remove.partition(&:child?)
|
||||||
.filter { !_1.child? || !champs_to_remove.include?(_1.parent) }
|
|
||||||
.each do |champ|
|
children_champs_to_remove.each(&:destroy!)
|
||||||
champ.rows.flatten.each(&:destroy!) if champ.repetition?
|
root_champs_to_remove.each do |champ|
|
||||||
champ.destroy!
|
champ.rows.flatten.each(&:destroy!) if champ.repetition?
|
||||||
end
|
champ.destroy!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue