Class: ConfidenceLevelsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/confidence_levels_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods inherited from ApplicationController

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) autocomplete



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/confidence_levels_controller.rb', line 19

def autocomplete
  confidence_levels = Queries::ControlledVocabularyTerm::Autocomplete.new(params[:term], project_id: sessions_current_project_id, of_type: ['ConfidenceLevel']).autocomplete

  data = confidence_levels.collect do |t|
    str = t.name + ': ' + t.definition
    {id: t.id,
     label: str,
     response_values: {
       params[:method] => t.id},
     label_html: str
    }
  end

  render json: data
end

- (Object) index

GET /index.json



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/confidence_levels_controller.rb', line 5

def index
  respond_to do |format|

    format.html do
      render '/shared/data/all/index' 
    end

    format.json do
      @controlled_vocabulary_terms = ConfidenceLevel.with_project_id(sessions_current_project_id).order(:position)
      render '/controlled_vocabulary_terms/index' 
    end
  end
end

- (Object) lookup



35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/confidence_levels_controller.rb', line 35

def lookup
  @confidence_levels = Queries::ControlledVocabularyTerm::Autocomplete::Query.new(term_param, project_id: sessions_current_project_id, object_type: ['ConfidenceLevel']).all
  render(json: @confidence_levels.collect { |t|
    {
      label: t.name,
      object_id: t.id,
      definition: t.definition
    }
  })
end

- (Object) select_options



46
47
48
# File 'app/controllers/confidence_levels_controller.rb', line 46

def select_options
  @confidence_levels = ConfidenceLevel.select_optimized(sessions_current_user_id, sessions_current_project_id, params.require(:klass))
end

- (Object) term_param (protected)



52
53
54
# File 'app/controllers/confidence_levels_controller.rb', line 52

def term_param
  params.require(:term)
end