end
end
+ # params[:order]:
+ #
+ # The order can be left empty to allow it to default.
+ # Or it can be a comma separated list of real database column names, one per model.
+ # Column names should always be qualified by a table name and a direction is optional, defaulting to asc
+ # (e.g. "collections.name" or "collections.name desc").
+ # If a column name is specified, that table will be sorted by that column.
+ # If there are objects from different models that will be shown (such as in Jobs and Pipelines tab),
+ # then a sort column name can optionally be specified for each model, passed as an comma-separated list (e.g. "jobs.script, pipeline_instances.name")
+ # Currently only one sort column name and direction can be specified for each model.
def load_filters_and_paging_params
- @order = params[:order] || 'created_at desc'
+ if params[:order].blank?
+ @order = 'created_at desc'
+ elsif params[:order].is_a? Array
+ @order = params[:order]
+ else
+ begin
+ @order = JSON.load(params[:order])
+ rescue
+ @order = params[:order].split(',')
+ end
+ end
@order = [@order] unless @order.is_a? Array
@limit ||= 200