force resync types_de_champ and types_de_champ_public/private
This commit is contained in:
parent
0db27b8718
commit
9596dac508
2 changed files with 16 additions and 2 deletions
|
@ -740,6 +740,10 @@ class Procedure < ApplicationRecord
|
|||
|
||||
move_new_children_to_new_parent_coordinate(new_draft)
|
||||
|
||||
# they are not aware of the new tdcs
|
||||
new_draft.types_de_champ_public.reset
|
||||
new_draft.types_de_champ_private.reset
|
||||
|
||||
new_draft
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,11 +33,13 @@ class ProcedureRevision < ApplicationRecord
|
|||
validate :conditions_are_valid?
|
||||
|
||||
def build_champs
|
||||
types_de_champ_public.map { |tdc| tdc.build_champ(revision: self) }
|
||||
# reload: it can be out of sync in test if some tdcs are added wihtout using add_tdc
|
||||
types_de_champ_public.reload.map { |tdc| tdc.build_champ(revision: self) }
|
||||
end
|
||||
|
||||
def build_champs_private
|
||||
types_de_champ_private.map { |tdc| tdc.build_champ(revision: self) }
|
||||
# reload: it can be out of sync in test if some tdcs are added wihtout using add_tdc
|
||||
types_de_champ_private.reload.map { |tdc| tdc.build_champ(revision: self) }
|
||||
end
|
||||
|
||||
def add_type_de_champ(params)
|
||||
|
@ -64,6 +66,10 @@ class ProcedureRevision < ApplicationRecord
|
|||
reorder(coordinate.siblings)
|
||||
end
|
||||
|
||||
# they are not aware of the addition
|
||||
types_de_champ_public.reset
|
||||
types_de_champ_private.reset
|
||||
|
||||
tdc
|
||||
rescue => e
|
||||
TypeDeChamp.new.tap { |tdc| tdc.errors.add(:base, e.message) }
|
||||
|
@ -101,6 +107,10 @@ class ProcedureRevision < ApplicationRecord
|
|||
children.each(&:destroy_if_orphan)
|
||||
tdc.destroy_if_orphan
|
||||
|
||||
# they are not aware of the removal
|
||||
types_de_champ_public.reset
|
||||
types_de_champ_private.reset
|
||||
|
||||
reorder(coordinate.siblings)
|
||||
|
||||
coordinate
|
||||
|
|
Loading…
Reference in a new issue