Class: ThinkFeelDoEngine::NavigatorController

Inherits:
ApplicationController show all
Includes:
Concerns::NavigatorEnabled
Defined in:
app/controllers/think_feel_do_engine/navigator_controller.rb

Overview

Uses the Navigator to direct a participant“s flow through the site.

Constant Summary collapse

URL_GENERATION_ALERT =
"We're sorry, the content you were looking "\
" for couldn't be found."

Constants inherited from ApplicationController

ApplicationController::CSRF_COOKIE_NAME, ApplicationController::CSRF_HEADER_NAME, ApplicationController::INACTIVE_MESSAGE, ApplicationController::ROOT_URI

Instance Method Summary collapse

Methods inherited from ApplicationController

#access_denied_resource_path, #after_sign_in_path_for, #after_sign_out_path_for

Instance Method Details

#show_contextObject



15
16
17
18
19
20
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 15

def show_context
  context_name = params[:context_name] || home_tool.try(:title)
  @navigator.initialize_context(context_name)

  render "show_content"
end

#show_locationObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 22

def show_location
  @navigator.initialize_location(
    module_id: params[:module_id],
    provider_id: params[:provider_id],
    content_position: params[:content_position]
  )

  complete_task_status(params[:module_id])

  render "show_content"
rescue ActiveRecord::RecordNotFound, ActionView::Template::Error
  @navigator.initialize_context(home_tool.title)
  flash[:alert] = "Unable to find that module."
  render "show_content"
end

#show_next_contentObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 38

def show_next_content
  @navigator.fetch_next_content

  if @navigator.current_module
    redirect_to navigator_location_path(
      module_id: @navigator.current_module.try(:id),
      provider_id: @navigator.current_content_provider
                     .try(:id),
      content_position: @navigator.content_position)
  else
    next_content_not_found
  end
end

#show_next_providerObject

Seek and redirect to the next content provider in order.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 62

def show_next_provider
  current_provider = @navigator.current_content_provider
  next_provider = current_provider

  while next_provider == current_provider
    @navigator.fetch_next_content
    next_provider = @navigator.current_content_provider
  end

  redirect_to navigator_location_path(
    module_id: @navigator.current_module.try(:id),
    provider_id: @navigator.current_content_provider.try(:id),
    content_position: @navigator.content_position
  )
end

#show_previous_contentObject



52
53
54
55
56
57
58
59
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 52

def show_previous_content
  @navigator.fetch_previous_content
  redirect_to navigator_location_path(
    module_id: @navigator.current_module.try(:id),
    provider_id: @navigator.current_content_provider.try(:id),
    content_position: @navigator.content_position
  )
end