TypeDeChamp: purge notice explicative lors d'un changement de type_champ
This commit is contained in:
parent
b588b77571
commit
3c5749e45a
1 changed files with 5 additions and 7 deletions
|
@ -210,14 +210,10 @@ class TypeDeChamp < ApplicationRecord
|
||||||
before_validation :check_mandatory
|
before_validation :check_mandatory
|
||||||
before_validation :normalize_libelle
|
before_validation :normalize_libelle
|
||||||
|
|
||||||
before_save :remove_piece_justificative_template, if: -> { type_champ_changed? }
|
before_save :remove_attachment, if: -> { type_champ_changed? }
|
||||||
before_validation :set_drop_down_list_options, if: -> { type_champ_changed? }
|
before_validation :set_drop_down_list_options, if: -> { type_champ_changed? }
|
||||||
before_save :remove_block, if: -> { type_champ_changed? }
|
before_save :remove_block, if: -> { type_champ_changed? }
|
||||||
|
|
||||||
after_save if: -> { @remove_piece_justificative_template } do
|
|
||||||
piece_justificative_template.purge_later
|
|
||||||
end
|
|
||||||
|
|
||||||
def valid?(context = nil)
|
def valid?(context = nil)
|
||||||
super
|
super
|
||||||
if dynamic_type.present?
|
if dynamic_type.present?
|
||||||
|
@ -767,9 +763,11 @@ class TypeDeChamp < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_piece_justificative_template
|
def remove_attachment
|
||||||
if !piece_justificative? && piece_justificative_template.attached?
|
if !piece_justificative? && piece_justificative_template.attached?
|
||||||
@remove_piece_justificative_template = true
|
piece_justificative_template.purge_later
|
||||||
|
elsif !explication? && notice_explicative.attached?
|
||||||
|
notice_explicative.purge_later
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue