Merge branch 'master' into 2060-edit-tags-in-workbench
[arvados.git] / apps / workbench / app / models / arvados_resource_list.rb
index a3032a67f295e88943d5987cca5c7fa2ace40b57..72495cfdb99caec2269d5fc681e5cbb3944cea6f 100644 (file)
@@ -15,6 +15,11 @@ class ArvadosResourceList
     self
   end
 
+  def order(orderby_spec)
+    @orderby_spec = orderby_spec
+    self
+  end
+
   def where(cond)
     cond = cond.dup
     cond.keys.each do |uuid_key|
@@ -46,6 +51,7 @@ class ArvadosResourceList
     }
     api_params[:eager] = '1' if @eager
     api_params[:limit] = @limit if @limit
+    api_params[:order] = @orderby_spec if @orderby_spec
     res = $arvados_api_client.api @resource_class, '', api_params
     @results = $arvados_api_client.unpack_api_response res
     self
@@ -94,4 +100,12 @@ class ArvadosResourceList
   def to_hash
     Hash[results.collect { |x| [x.uuid, x] }]
   end
+
+  def empty?
+    results.empty?
+  end
+
+  def items_available
+    results.items_available if results.respond_to? :items_available
+  end
 end