Project

General

Profile

Feature #21623 » redmine_3.2.0_21623.diff

Jérôme BATAILLE, 2016-04-07 01:06

View differences:

app/models/journal.rb
end
if @custom_values_before_change
# custom fields changes
journalized.custom_field_values.each {|c|
##################
# Smile fix #21623 : re-insert removed custom fields with nil value
# TODO check if custom_field_values has to be fixed to take that in account
cf_values = journalized.custom_field_values.dup # Dupped because cached in an instance variable
custom_fields = {} # cached locally
@custom_values_before_change.each{|i, v|
cfv = cf_values.detect {|c| c.custom_field_id == i}
next if cfv # On a not deleted custom field, or already re-added
cf = custom_fields[i]
if cf.nil?
cf = CustomField.find_by_id(i)
end
if cf # Custom field has not been deleted in between
cfv = CustomFieldValue.new
cfv.custom_field = cf
cfv.value = nil
# Re-add it in the list
cf_values << cfv
end
}
# END -- Smile fix #21623
#########################
# Smile fix #21623 : journalized.custom_field_values -> cf_values
cf_values.each {|c|
before = @custom_values_before_change[c.custom_field_id]
after = c.value
next if before == after || (before.blank? && after.blank?)
(2-2/3)