+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
class TrashItemsController < ApplicationController
def model_class
Collection
end
+ def index_pane_list
+ %w(Trashed_collections Trashed_projects)
+ end
+
def find_objects_for_index
# If it's not the index rows partial display, just return
# The /index request will again be invoked to display the
trashed_items
if @objects.any?
+ @objects = @objects.sort_by { |obj| obj.trash_at }.reverse
@next_page_filters = next_page_filters('<=')
@next_page_href = url_for(partial: :trash_rows,
filters: @next_page_filters.to_json)
- preload_links_for_objects(@objects.to_a)
else
@next_page_href = nil
end
@next_page_href
end
+ def next_page_filters nextpage_operator
+ next_page_filters = @filters.reject do |attr, op, val|
+ (attr == 'trash_at' and op == nextpage_operator) or
+ (attr == 'uuid' and op == 'not in')
+ end
+
+ if @objects.any?
+ last_trash_at = @objects.last.trash_at
+
+ last_uuids = []
+ @objects.each do |obj|
+ last_uuids << obj.uuid if obj.trash_at.eql?(last_trash_at)
+ end
+
+ next_page_filters += [['trash_at', nextpage_operator, last_trash_at]]
+ next_page_filters += [['uuid', 'not in', last_uuids]]
+ end
+
+ next_page_filters
+ end
+
def trashed_items
# API server index doesn't return manifest_text by default, but our
# callers want it unless otherwise specified.
if params[:search].andand.length.andand > 0
tags = Link.where(any: ['contains', params[:search]])
- @objects = (base_search.limit(limit).offset(offset).where(uuid: tags.collect(&:head_uuid)) |
- base_search.where(any: ['contains', params[:search]])).
- uniq { |c| c.uuid }
+ base_search = base_search.limit(limit).offset(offset)
+ @objects = (base_search.where(uuid: tags.collect(&:head_uuid)) |
+ base_search.where(any: ['contains', params[:search]])).
+ uniq { |c| c.uuid }
else
@objects = base_search.limit(limit).offset(offset)
end
-
- @links = Link.where(head_uuid: @objects.collect(&:uuid))
- @collection_info = {}
- @objects.each do |c|
- @collection_info[c.uuid] = {
- tag_links: [],
- wanted: false,
- wanted_by_me: false,
- provenance: [],
- links: []
- }
- end
- @links.each do |link|
- @collection_info[link.head_uuid] ||= {}
- info = @collection_info[link.head_uuid]
- case link.link_class
- when 'tag'
- info[:tag_links] << link
- when 'resources'
- info[:wanted] = true
- info[:wanted_by_me] ||= link.tail_uuid == current_user.uuid
- when 'provenance'
- info[:provenance] << link.name
- end
- info[:links] << link
- end
- @request_url = request.url
end
def untrash_items