4285: prepend './' to file path being retrieved when it is in a subdir in a collection.
[arvados.git] / apps / workbench / app / controllers / search_controller.rb
index 510ba6f35f0ef3066c3674450585bd96fdac09e7..6f209a5a9e0d11fc0a1a0fbaab0b6fe8b47834cc 100644 (file)
@@ -1,6 +1,26 @@
 class SearchController < ApplicationController
   def find_objects_for_index
-    @objects = Group.contents(limit: @limit, offset: @offset, filters: @filters)
+    search_what = Group
+    if params[:project_uuid]
+      # Special case for "search all things in project":
+      @filters = @filters.select do |attr, operator, operand|
+        not (attr == 'owner_uuid' and operator == '=')
+      end
+      # Special case for project_uuid is a user uuid:
+      if ArvadosBase::resource_class_for_uuid(params[:project_uuid]) == User
+        search_what = User.find params[:project_uuid]
+      else
+        search_what = Group.find params[:project_uuid]
+      end
+    end
+    @objects = search_what.contents(limit: @limit,
+                                    offset: @offset,
+                                    filters: @filters,
+                                    include_linked: true)
     super
   end
+
+  def next_page_href with_params={}
+    super with_params.merge(last_object_class: @objects.last.class.to_s)
+  end
 end