X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/81f6ebc139c29723b62fc0f5e6d0588dfb85897b..850bc55e74beb1d444bf518ce0be9cb0eacaa158:/apps/workbench/app/controllers/application_controller.rb?ds=sidebyside diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 4f5d8fdcd2..27e388be20 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -105,8 +105,28 @@ class ApplicationController < ActionController::Base 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