Merge pull request #3210 from urbanrotnik/ur-sci-4179-v2

Fix Role sorting [SCI-4179]
This commit is contained in:
Alex Kriuchykhin 2021-03-16 14:08:26 +01:00 committed by GitHub
commit 936322b294
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -17,7 +17,7 @@ class TeamUsersDatatable < CustomDatatable
'User.full_name', 'User.full_name',
'User.email', 'User.email',
'UserTeam.role', 'UserTeam.role',
'User.confirmed_at', 'UserTeam.created_at',
'User.confirmed_at', 'User.confirmed_at',
] ]
end end

View file

@ -63,6 +63,15 @@ class TeamsDatatable < CustomDatatable
elsif order_params['dir'] == 'desc' elsif order_params['dir'] == 'desc'
return records.reverse return records.reverse
end end
elsif sort_column(order_params) == 'user_teams.role'
records_with_role = records.where(user: @user).order(role: :asc)
records_with_no_role = records.where.not(user: @user)
records = records_with_no_role + records_with_role
if order_params['dir'] == 'asc'
records
else
records.reverse
end
else else
super(records) super(records)
end end