Class: UiJobWizardController

Inherits:
Api::V2::BaseController
  • Object
show all
Defined in:
app/controllers/ui_job_wizard_controller.rb

Instance Method Summary collapse

Instance Method Details

#action_permissionObject



34
35
36
# File 'app/controllers/ui_job_wizard_controller.rb', line 34

def action_permission
  :view_job_templates
end

#categoriesObject



2
3
4
5
6
7
8
9
# File 'app/controllers/ui_job_wizard_controller.rb', line 2

def categories
  job_categories = resource_scope
                   .search_for("job_category ~ \"#{params[:search]}\"")
                   .select(:job_category).distinct
                   .reorder(:job_category)
                   .pluck(:job_category)
  render :json => {:job_categories =>job_categories}
end

#map_template_inputs(template_inputs_with_foreign) ⇒ Object



26
27
28
# File 'app/controllers/ui_job_wizard_controller.rb', line 26

def map_template_inputs(template_inputs_with_foreign)
  template_inputs_with_foreign.map { |input| input.attributes.merge({:resource_type => input.resource_type&.tableize }) }
end

#resource_classObject



30
31
32
# File 'app/controllers/ui_job_wizard_controller.rb', line 30

def resource_class
  JobTemplate
end

#resource_name(nested_resource = nil) ⇒ Object



22
23
24
# File 'app/controllers/ui_job_wizard_controller.rb', line 22

def resource_name(nested_resource = nil)
  nested_resource || 'job_template'
end

#templateObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/ui_job_wizard_controller.rb', line 11

def template
  job_template = JobTemplate.authorized.find(params[:id])
  advanced_template_inputs, template_inputs = map_template_inputs(job_template.template_inputs_with_foreign).partition { |x| x["advanced"] }
  render :json => {
    :job_template => job_template,
    :effective_user => job_template.effective_user,
    :template_inputs => template_inputs,
    :advanced_template_inputs => advanced_template_inputs,
  }
end