1 class TrashItemsController < ApplicationController
6 def find_objects_for_index
7 # If it's not the index rows partial display, just return
8 # The /index request will again be invoked to display the
9 # partial at which time, we will be using the objects found.
10 return if !params[:partial]
15 @next_page_filters = next_page_filters('<=')
16 @next_page_href = url_for(partial: :trash_rows,
17 filters: @next_page_filters.to_json)
18 preload_links_for_objects(@objects.to_a)
24 def next_page_href with_params={}
29 # API server index doesn't return manifest_text by default, but our
30 # callers want it unless otherwise specified.
31 @select ||= Collection.columns.map(&:name)
32 limit = if params[:limit] then params[:limit].to_i else 100 end
33 offset = if params[:offset] then params[:offset].to_i else 0 end
35 base_search = Collection.select(@select).include_trash(true).where(is_trashed: true)
36 base_search = base_search.filter(params[:filters]) if params[:filters]
38 if params[:search].andand.length.andand > 0
39 tags = Link.where(any: ['contains', params[:search]])
40 @objects = (base_search.limit(limit).offset(offset).where(uuid: tags.collect(&:head_uuid)) |
41 base_search.where(any: ['contains', params[:search]])).
44 @objects = base_search.limit(limit).offset(offset)
47 @links = Link.where(head_uuid: @objects.collect(&:uuid))
50 @collection_info[c.uuid] = {
59 @collection_info[link.head_uuid] ||= {}
60 info = @collection_info[link.head_uuid]
63 info[:tag_links] << link
66 info[:wanted_by_me] ||= link.tail_uuid == current_user.uuid
68 info[:provenance] << link.name
72 @request_url = request.url
76 params[:item_uuids] = [params[:item_uuid]]
78 render template: 'untrash_items'
84 updates = {trash_at: nil}
85 #updates[:trash_at] = nil
87 params[:item_uuids].collect { |uuid| ArvadosBase.find uuid }.each do |item|
88 item.update_attributes updates
89 @untrashed_uuids << item.uuid
92 render_template :untrashed_items