fixup! perf(editor): better perf to add, destroy, update, move up, move down and move with number
This commit is contained in:
parent
aae26a863a
commit
0e5768ec5b
3 changed files with 20 additions and 10 deletions
|
@ -110,6 +110,7 @@ module Administrateurs
|
||||||
flash.alert = errors
|
flash.alert = errors
|
||||||
else
|
else
|
||||||
@coordinate = draft.remove_type_de_champ(params[:stable_id])
|
@coordinate = draft.remove_type_de_champ(params[:stable_id])
|
||||||
|
@coordinate.association(:revision).target = ProcedureRevision.includes_for_compare.find(coordinate.revision.id)
|
||||||
if @coordinate.present?
|
if @coordinate.present?
|
||||||
@destroyed = @coordinate
|
@destroyed = @coordinate
|
||||||
@morphed = champ_components_starting_at(@coordinate)
|
@morphed = champ_components_starting_at(@coordinate)
|
||||||
|
|
|
@ -17,11 +17,23 @@ class ProcedureRevision < ApplicationRecord
|
||||||
|
|
||||||
scope :ordered, -> { order(:created_at) }
|
scope :ordered, -> { order(:created_at) }
|
||||||
scope :includes_for_compare, -> {
|
scope :includes_for_compare, -> {
|
||||||
includes(revision_types_de_champ: {
|
includes(
|
||||||
type_de_champ: { notice_explicative_attachment: :blob, piece_justificative_template_attachment: :blob, revision: [], procedure: [] },
|
revision_types_de_champ: {
|
||||||
revision: [],
|
type_de_champ: { notice_explicative_attachment: :blob, piece_justificative_template_attachment: :blob, revision: [], procedure: [] },
|
||||||
procedure: []
|
revision: [],
|
||||||
})
|
procedure: []
|
||||||
|
},
|
||||||
|
revision_types_de_champ_public: {
|
||||||
|
type_de_champ: { notice_explicative_attachment: :blob, piece_justificative_template_attachment: :blob, revision: [], procedure: [] },
|
||||||
|
revision: [],
|
||||||
|
procedure: []
|
||||||
|
},
|
||||||
|
revision_types_de_champ_private: {
|
||||||
|
type_de_champ: { notice_explicative_attachment: :blob, piece_justificative_template_attachment: :blob, revision: [], procedure: [] },
|
||||||
|
revision: [],
|
||||||
|
procedure: []
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
validate :conditions_are_valid?
|
validate :conditions_are_valid?
|
||||||
validate :header_sections_are_valid?
|
validate :header_sections_are_valid?
|
||||||
|
@ -60,7 +72,6 @@ class ProcedureRevision < ApplicationRecord
|
||||||
revision_types_de_champ.create!(h)
|
revision_types_de_champ.create!(h)
|
||||||
end
|
end
|
||||||
|
|
||||||
# they are not aware of the addition
|
|
||||||
tdc
|
tdc
|
||||||
rescue => e
|
rescue => e
|
||||||
TypeDeChamp.new.tap { |tdc| tdc.errors.add(:base, e.message) }
|
TypeDeChamp.new.tap { |tdc| tdc.errors.add(:base, e.message) }
|
||||||
|
@ -101,12 +112,8 @@ class ProcedureRevision < ApplicationRecord
|
||||||
children.each(&:destroy_if_orphan)
|
children.each(&:destroy_if_orphan)
|
||||||
tdc.destroy_if_orphan
|
tdc.destroy_if_orphan
|
||||||
|
|
||||||
# they are not aware of the removal
|
|
||||||
coordinate.siblings.where("position >= ?", coordinate.position).update_all("position = position - 1")
|
coordinate.siblings.where("position >= ?", coordinate.position).update_all("position = position - 1")
|
||||||
|
|
||||||
types_de_champ_public.reset
|
|
||||||
types_de_champ_private.reset
|
|
||||||
|
|
||||||
coordinate
|
coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ describe InitiationProcedureConcern do
|
||||||
subject { Procedure.create_initiation_procedure(administrateur) }
|
subject { Procedure.create_initiation_procedure(administrateur) }
|
||||||
|
|
||||||
it "returns a new procedure" do
|
it "returns a new procedure" do
|
||||||
|
subject
|
||||||
|
subject.reload
|
||||||
expect(subject).to be_valid
|
expect(subject).to be_valid
|
||||||
expect(subject.defaut_groupe_instructeur.instructeurs.count).to eq(1)
|
expect(subject.defaut_groupe_instructeur.instructeurs.count).to eq(1)
|
||||||
expect(subject.draft_revision.types_de_champ_public).not_to be_empty
|
expect(subject.draft_revision.types_de_champ_public).not_to be_empty
|
||||||
|
|
Loading…
Reference in a new issue