1 class TrashItemsController < ApplicationController
10 def find_objects_for_index
11 # If it's not the index rows partial display, just return
12 # The /index request will again be invoked to display the
13 # partial at which time, we will be using the objects found.
14 return if !params[:partial]
19 @objects = @objects.sort_by { |obj| obj.trash_at }.reverse
20 @next_page_filters = next_page_filters('<=')
21 @next_page_href = url_for(partial: :trash_rows,
22 filters: @next_page_filters.to_json)
28 def next_page_href with_params={}
32 def next_page_filters nextpage_operator
33 next_page_filters = @filters.reject do |attr, op, val|
34 (attr == 'trash_at' and op == nextpage_operator) or
35 (attr == 'uuid' and op == 'not in')
39 last_trash_at = @objects.last.trash_at
42 @objects.each do |obj|
43 last_uuids << obj.uuid if obj.trash_at.eql?(last_trash_at)
46 next_page_filters += [['trash_at', nextpage_operator, last_trash_at]]
47 next_page_filters += [['uuid', 'not in', last_uuids]]
54 # API server index doesn't return manifest_text by default, but our
55 # callers want it unless otherwise specified.
56 @select ||= Collection.columns.map(&:name)
57 limit = if params[:limit] then params[:limit].to_i else 100 end
58 offset = if params[:offset] then params[:offset].to_i else 0 end
60 base_search = Collection.select(@select).include_trash(true).where(is_trashed: true)
61 base_search = base_search.filter(params[:filters]) if params[:filters]
63 if params[:search].andand.length.andand > 0
64 tags = Link.where(any: ['contains', params[:search]])
65 base_search = base_search.limit(limit).offset(offset)
66 @objects = (base_search.where(uuid: tags.collect(&:head_uuid)) |
67 base_search.where(any: ['contains', params[:search]])).
70 @objects = base_search.limit(limit).offset(offset)
77 updates = {trash_at: nil}
79 Collection.include_trash(1).where(uuid: params[:selection]).each do |c|
81 @untrashed_uuids << c.uuid
84 respond_to do |format|