fixup! feat(type_de_champ_editor): move champs after another champ.
This commit is contained in:
parent
8eb6e5d6bb
commit
2281e3de4b
2 changed files with 9 additions and 4 deletions
|
@ -72,7 +72,12 @@ module Administrateurs
|
|||
@destroyed = @coordinate
|
||||
@created = champ_component_from(@coordinate)
|
||||
@morphed = @coordinate.siblings
|
||||
@morphed = @morphed.where("position > ?", [from, to].min).where("position <= ?", [from, to].max)
|
||||
if from > to # case of moved up, update components from target (> plus one) to origin
|
||||
@morphed = @morphed.where("position > ?", to).where("position <= ?", from)
|
||||
else # case of moved down, update components from origin up to target (< minus one)
|
||||
@morphed = @morphed.where("position >= ?", from).where("position < ?", to)
|
||||
end
|
||||
|
||||
@morphed = @morphed.map { |c| champ_component_from(c) }
|
||||
end
|
||||
|
||||
|
|
|
@ -186,9 +186,9 @@ describe Administrateurs::TypesDeChampController, type: :controller do
|
|||
it do
|
||||
is_expected.to have_http_status(:ok)
|
||||
[first_coordinate, second_coordinate, third_coordinate].map(&:reload)
|
||||
expect(assigns(:coordinate).stable_id).to eq(first_coordinate.stable_id)
|
||||
expect(assigns(:destroyed).stable_id).to eq(first_coordinate.stable_id)
|
||||
expect(extract_libelle(assigns(:created))).to eq(['l3', []])
|
||||
expect(assigns(:coordinate).stable_id).to eq(second_coordinate.stable_id)
|
||||
expect(assigns(:destroyed).stable_id).to eq(second_coordinate.stable_id)
|
||||
expect(extract_libelle(assigns(:created))).to eq(['l3', ['l1']])
|
||||
expect(morpheds).to eq([['l3', ['l1']], ['l2', ['l1', 'l3']]])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue