Add sorting to list of locations [SCI-11047]

This commit is contained in:
Anton 2024-09-13 13:10:06 +02:00
parent 173fdda28a
commit e20467bf51
2 changed files with 23 additions and 2 deletions

View file

@ -132,7 +132,7 @@ export default {
{ {
field: 'reminders', field: 'reminders',
headerName: this.i18n.t('storage_locations.show.table.reminders'), headerName: this.i18n.t('storage_locations.show.table.reminders'),
sortable: true, sortable: false,
cellRenderer: RemindersRender cellRenderer: RemindersRender
}, },
{ {
@ -149,7 +149,7 @@ export default {
{ {
field: 'stock', field: 'stock',
headerName: this.i18n.t('storage_locations.show.table.stock'), headerName: this.i18n.t('storage_locations.show.table.stock'),
sortable: true sortable: false
}]; }];
return columns; return columns;

View file

@ -13,5 +13,26 @@ module Lists
end end
def filter_records; 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
end end