Class: TopicsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/topics_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 inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) autocomplete

TODO:

This format very different, should it be made same as other autocompletes?



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

def autocomplete
  predicates = Topic.find_for_autocomplete(params.merge(project_id: sessions_current_project_id))

  data = predicates.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) get_definition



32
33
34
35
# File 'app/controllers/topics_controller.rb', line 32

def get_definition
  @topic = Topic.find(params[:id])
  render(:json => {definition: @topic.definition})
end

- (Object) lookup_topic



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/topics_controller.rb', line 21

def lookup_topic
  @topics = Topic.find_for_autocomplete(params.merge(project_id: sessions_current_project_id))
  render(:json => @topics.collect { |t|
           {
             label:     t.name,
             object_id: t.id,
             definition: t.definition
           }
         })
end