User ordering
Run the task new_ui:save_users
This commit is contained in:
1 parent
dc3593c162
commit
f81894af90
10 files changed
+125
-12
No files matched your search
@@ -240,6 +240,32 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit_order
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
def update_order
|
||||
if params[:users].present?
|
||||
params[:users].values.sort.each do |pair|
|
||||
to_go = pair[0].to_i
|
||||
if to_go > 0
|
||||
user_at_position = User.where(position: to_go - 1).first
|
||||
user = User.find(pair[1])
|
||||
if user_at_position && !user_at_position == user
|
||||
if user.position > user_at_position.position
|
||||
user.move_above(user_at_position)
|
||||
else
|
||||
user.move_below(user_at_position)
|
||||
end
|
||||
elsif to_go > User.count
|
||||
user.move_to_bottom
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@users = User.all
|
||||
end
|
||||
|
||||
protected
|
||||
def get_tags
|
||||
|
||||
Reference in new issue
Block a user