mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 06:35:56 +08:00
Merge pull request #7852 from aignatov-bio/ai-sci-11047-add-sorting-to-list-of-locations
Add sorting to list of locations [SCI-11047]
This commit is contained in:
commit
53c6056706
|
@ -132,7 +132,7 @@ export default {
|
|||
{
|
||||
field: 'reminders',
|
||||
headerName: this.i18n.t('storage_locations.show.table.reminders'),
|
||||
sortable: true,
|
||||
sortable: false,
|
||||
cellRenderer: RemindersRender
|
||||
},
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ export default {
|
|||
{
|
||||
field: 'stock',
|
||||
headerName: this.i18n.t('storage_locations.show.table.stock'),
|
||||
sortable: true
|
||||
sortable: false
|
||||
}];
|
||||
|
||||
return columns;
|
||||
|
|
|
@ -13,5 +13,26 @@ module Lists
|
|||
end
|
||||
|
||||
def filter_records; end
|
||||
|
||||
def sort_records
|
||||
return unless @params[:order]
|
||||
|
||||
sort = "#{order_params[:column]}_#{sort_direction(order_params)}"
|
||||
|
||||
case sort
|
||||
when 'position_formatted_ASC'
|
||||
@records = @records.order(Arel.sql("metadata -> 'position' -> 0 ASC, metadata -> 'position' -> 1 ASC"))
|
||||
when 'position_formatted_DESC'
|
||||
@records = @records.order(Arel.sql("metadata -> 'position' -> 0 DESC, metadata -> 'position' -> 1 DESC"))
|
||||
when 'row_id_ASC'
|
||||
@records = @records.order(repository_row_id: :asc)
|
||||
when 'row_id_DESC'
|
||||
@records = @records.order(repository_row_id: :desc)
|
||||
when 'row_name_ASC'
|
||||
@records = @records.joins(:repository_row).order('repository_rows.name ASC')
|
||||
when 'row_name_DESC'
|
||||
@records = @records.joins(:repository_row).order('repository_rows.name DESC')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue