mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-21 15:36:22 +08:00
Merge pull request #3210 from urbanrotnik/ur-sci-4179-v2
Fix Role sorting [SCI-4179]
This commit is contained in:
commit
936322b294
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue