Fix sorted table pagination [SCI-10359] (#7264)

* Fix table pagination when sorting by columns with non unique values [SCI-10359]

* Refactor solution [SCI-10359]
This commit is contained in:
Soufiane 2024-03-14 17:20:26 +00:00 committed by GitHub
parent 660a067433
commit 3f4c4dd222
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -40,7 +40,7 @@ module Lists
return unless @params[:order]
sort_by = "#{sortable_columns[order_params[:column].to_sym]} #{sort_direction(order_params)}"
@records = @records.order(sort_by)
@records = @records.order(sort_by).order(:id)
end
end
end

View file

@ -40,10 +40,9 @@ module Lists
if sorted_column == 'label_templates.description'
sort_by = "COALESCE(label_templates.description, '') ASC"
sort_by = "COALESCE(label_templates.description, '') DESC" if sort_direction(order_params) == 'DESC'
@records = @records.order(Arel.sql(sort_by))
@records = @records.order(Arel.sql(sort_by)).order(:id)
else
sort_by = "#{sorted_column} #{sort_direction(order_params)}"
@records = @records.order(sort_by)
super
end
end