Merge pull request #5862 from tchak/fix-champs-repetition

Stop crashing when removed repetition row is submitted
This commit is contained in:
Paul Chavard 2021-01-27 17:43:29 +01:00 committed by GitHub
commit 2eae5c4afe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -346,6 +346,11 @@ module Users
if champs_params[:dossier]
@dossier.assign_attributes(champs_params[:dossier])
# FIXME in some cases a removed repetition bloc row is submitted.
# In this case it will be trated as a new records and action will fail.
@dossier.champs.filter(&:repetition?).each do |champ|
champ.champs = champ.champs.filter(&:persisted?)
end
if @dossier.champs.any?(&:changed?)
@dossier.last_champ_updated_at = Time.zone.now
end