closes #11652
[arvados.git] / apps / workbench / app / controllers / search_controller.rb
1 class SearchController < ApplicationController
2   def find_objects_for_index
3     search_what = Group
4     if params[:project_uuid]
5       # Special case for "search all things in project":
6       @filters = @filters.select do |attr, operator, operand|
7         not (attr == 'owner_uuid' and operator == '=')
8       end
9       # Special case for project_uuid is a user uuid:
10       if ArvadosBase::resource_class_for_uuid(params[:project_uuid]) == User
11         search_what = User.find params[:project_uuid]
12       else
13         search_what = Group.find params[:project_uuid]
14       end
15     end
16     @objects = search_what.contents(limit: @limit,
17                                     offset: @offset,
18                                     recursive: true,
19                                     count: 'none',
20                                     last_object_class: params["last_object_class"],
21                                     filters: @filters)
22     super
23   end
24
25   def next_page_href with_params={}
26     super with_params.merge(last_object_class: @objects.last.class.to_s,
27                             project_uuid: params[:project_uuid],
28                             recursive: true,
29                             count: 'none',
30                             filters: @filters.to_json)
31   end
32 end