mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 03:06:28 +08:00
Fix normalize_module_position method [SCI-5508]
This commit is contained in:
parent
a89c5fef13
commit
58a5126a13
2 changed files with 6 additions and 2 deletions
|
@ -65,7 +65,7 @@ class ExperimentsController < ApplicationController
|
|||
def canvas
|
||||
redirect_to module_archive_experiment_path(@experiment) if @experiment.archived_branch?
|
||||
@project = @experiment.project
|
||||
@active_modules = @experiment.my_modules.active.includes(:tags, :inputs, :outputs)
|
||||
@active_modules = @experiment.my_modules.active.order(:name).includes(:tags, :inputs, :outputs)
|
||||
current_team_switch(@project.team)
|
||||
end
|
||||
|
||||
|
|
|
@ -471,7 +471,11 @@ class Experiment < ApplicationRecord
|
|||
x_diff = my_modules.active.pluck(:x).min
|
||||
y_diff = my_modules.active.pluck(:y).min
|
||||
|
||||
my_modules.active.each do |m|
|
||||
moving_direction = {
|
||||
x: x_diff.positive? ? :asc : :desc,
|
||||
y: y_diff.positive? ? :asc : :desc
|
||||
}
|
||||
my_modules.active.order(moving_direction).each do |m|
|
||||
m.update!(x: m.x - x_diff, y: m.y - y_diff)
|
||||
end
|
||||
my_modules.reload
|
||||
|
|
Loading…
Reference in a new issue