fix remove type de champ
This commit is contained in:
parent
6bf52b1f99
commit
5dd8bbe797
1 changed files with 9 additions and 7 deletions
|
@ -86,14 +86,16 @@ class ProcedureRevision < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_type_de_champ(stable_id)
|
def remove_type_de_champ(stable_id)
|
||||||
type_de_champ = find_type_de_champ_by_stable_id(stable_id)
|
coordinate = revision_types_de_champ
|
||||||
|
.joins(:type_de_champ)
|
||||||
|
.find_by(type_de_champ: { stable_id: stable_id })
|
||||||
|
|
||||||
if type_de_champ.only_present_on_draft?
|
tdc = coordinate.type_de_champ
|
||||||
type_de_champ.destroy
|
|
||||||
elsif type_de_champ.parent.present?
|
coordinate.destroy
|
||||||
find_or_clone_type_de_champ(stable_id).destroy
|
|
||||||
else
|
if tdc.revision_types_de_champ.empty?
|
||||||
types_de_champ.delete(type_de_champ)
|
tdc.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue