var $target = $(this).closest('table').find('[data-infinite-content-params-attr]');
var params_attr = 'infinite-content-params-' + $target.data('infinite-content-params-attr');
var params = $target.data(params_attr) || {};
- params.order = $(this).data('sort-order') + ' ' + direction;
- $target.data('params_attr', params);
+ params.order = $(this).data('sort-order').split(",").join( ' ' + direction + ', ' ) + ' ' + direction;
+ $target.data(params_attr, params);
$target.trigger('refresh-content');
}).
on('ready arv:pane:loaded refresh-content', function() {
# params[:order]:
#
- # The order can be unspecified, or it can be a column name.
+ # 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 array (e.g. "['jobs.description', 'pipeline_instances.name']")
+ # 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
if params[:order].blank?
@order = 'created_at desc'
- elsif params[:order].starts_with? '['
- @order = Oj.load params[:order]
- else
- @order = params[:order]
+ elsif !params[:order].is_a? Array
+ @order = params[:order].split(',')
end
@order = [@order] unless @order.is_a? Array
<%= render_pane 'tab_contents', to_string: true, locals: {
- filters: [['uuid', 'is_a', ["arvados#job", "arvados#pipelineInstance"]]]
+ filters: [['uuid', 'is_a', ["arvados#job", "arvados#pipelineInstance"]]],
+ sortable_columns: { 'name' => 'jobs.script, pipeline_instances.name' }
}.merge(local_assigns) %>
<th></th>
<th></th>
<% sort_order = sortable_columns['name'] %>
- <th <%= raw sort_order.nil? ? "" : "data-sort-order='#{sort_order}'" %>>
+ <th <% if !sort_order.nil? %>
+ data-sort-order='<%= raw sort_order %>'
+ <% end %> >
name
</th>
- <th>description</th>
+ <% sort_order = sortable_columns['description'] %>
+ <th <% if !sort_order.nil? %>
+ data-sort-order='<%= raw sort_order %>'
+ <% end %> >
+ description
+ </th>
</tr>
</thead>
</table>