review(sim): some review suggestions

Co-authored-by: LeSim <mail@simon.lehericey.net>
This commit is contained in:
mfo 2024-01-22 11:27:09 +01:00
parent 5c049a1c0f
commit 89d2c57cb2

View file

@ -41,14 +41,16 @@ class ProcedureRevision < ApplicationRecord
after_stable_id = params.delete(:after_stable_id)
after_coordinate, _ = coordinate_and_tdc(after_stable_id)
siblings = siblings_for(parent_coordinate:, private_tdc: params[:private] || params['private'])
siblings = siblings_for(parent_coordinate:, private_tdc: params[:private])
tdc = TypeDeChamp.new(params)
if tdc.save
# moving all the impacted tdc down
position = next_position_for(after_coordinate:, siblings:)
h = { type_de_champ: tdc, parent_id: parent_id, position: position }
siblings.where("position >= ?", position).update_all("position = position + 1")
# insertion of the new tdc
h = { type_de_champ: tdc, parent_id: parent_id, position: position }
revision_types_de_champ.create!(h)
end