fix(revision): (re)move child type de champ should clone parent for now
This commit is contained in:
parent
85c20784a2
commit
8d9929aa9f
1 changed files with 11 additions and 1 deletions
|
@ -54,7 +54,7 @@ class ProcedureRevision < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_clone_type_de_champ(stable_id)
|
def find_or_clone_type_de_champ(stable_id)
|
||||||
type_de_champ = find_type_de_champ_by_stable_id(stable_id)
|
type_de_champ = types_de_champ.find_by!(stable_id: stable_id)
|
||||||
|
|
||||||
if type_de_champ.only_present_on_draft?
|
if type_de_champ.only_present_on_draft?
|
||||||
type_de_champ
|
type_de_champ
|
||||||
|
@ -66,6 +66,9 @@ class ProcedureRevision < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_type_de_champ(stable_id, position)
|
def move_type_de_champ(stable_id, position)
|
||||||
|
# Ensure that if this is a child, it's parent is cloned to the new revision
|
||||||
|
clone_parent_to_draft_revision(stable_id)
|
||||||
|
|
||||||
coordinate = revision_types_de_champ
|
coordinate = revision_types_de_champ
|
||||||
.joins(:type_de_champ)
|
.joins(:type_de_champ)
|
||||||
.find_by(type_de_champ: { stable_id: stable_id })
|
.find_by(type_de_champ: { stable_id: stable_id })
|
||||||
|
@ -78,6 +81,9 @@ class ProcedureRevision < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_type_de_champ(stable_id)
|
def remove_type_de_champ(stable_id)
|
||||||
|
# Ensure that if this is a child, it's parent is cloned to the new revision
|
||||||
|
clone_parent_to_draft_revision(stable_id)
|
||||||
|
|
||||||
coordinate = revision_types_de_champ
|
coordinate = revision_types_de_champ
|
||||||
.joins(:type_de_champ)
|
.joins(:type_de_champ)
|
||||||
.find_by(type_de_champ: { stable_id: stable_id })
|
.find_by(type_de_champ: { stable_id: stable_id })
|
||||||
|
@ -398,7 +404,11 @@ class ProcedureRevision < ApplicationRecord
|
||||||
cloned_type_de_champ
|
cloned_type_de_champ
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clone_parent_to_draft_revision(stable_id)
|
||||||
|
type_de_champ = types_de_champ.find_by!(stable_id: stable_id)
|
||||||
|
|
||||||
|
if type_de_champ.parent_id.present? && type_de_champ.only_present_on_draft?
|
||||||
|
find_or_clone_type_de_champ(type_de_champ.parent.stable_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue