mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Merge pull request #3210 from urbanrotnik/ur-sci-4179-v2
Fix Role sorting [SCI-4179]
This commit is contained in:
commit
936322b294
2 changed files with 10 additions and 1 deletions
|
@ -17,7 +17,7 @@ class TeamUsersDatatable < CustomDatatable
|
|||
'User.full_name',
|
||||
'User.email',
|
||||
'UserTeam.role',
|
||||
'User.confirmed_at',
|
||||
'UserTeam.created_at',
|
||||
'User.confirmed_at',
|
||||
]
|
||||
end
|
||||
|
|
|
@ -63,6 +63,15 @@ class TeamsDatatable < CustomDatatable
|
|||
elsif order_params['dir'] == 'desc'
|
||||
return records.reverse
|
||||
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
|
||||
super(records)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue