9767: include workflows in the template chooser.
[arvados.git] / apps / workbench / app / controllers / work_unit_templates_controller.rb
1 class WorkUnitTemplatesController < ApplicationController
2   def find_objects_for_index
3     return if !params[:partial]
4
5     @limit = 20
6     @filters = @filters || []
7
8     # get next page of pipeline_templates
9     filters = @filters + [["uuid", "is_a", ["arvados#pipelineTemplate"]]]
10     pipelines = PipelineTemplate.limit(@limit).order(["created_at desc"]).filter(filters)
11
12     # get next page of workflows
13     filters = @filters + [["uuid", "is_a", ["arvados#workflow"]]]
14     workflows = Workflow.limit(@limit).order(["created_at desc"]).filter(filters)
15
16     @objects = (pipelines.to_a + workflows.to_a).sort_by(&:created_at).reverse.first(@limit)
17  
18     if @objects.any?
19       @next_page_filters = next_page_filters('<=')
20       @next_page_href = url_for(partial: :choose_rows,
21                                 filters: @next_page_filters.to_json)
22     else
23       @next_page_href = nil
24     end
25   end
26
27   def next_page_href with_params={}
28     @next_page_href
29   end
30 end