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

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



12
13
14
15
16
17
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 12

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

  render "show_content"
end

#show_locationObject



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

def show_location
  @navigator.initialize_location(
    module_id: params[:module_id],
    provider_id: params[:provider_id],
    content_position: params[:content_position]
  )
  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



32
33
34
35
36
37
38
39
40
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 32

def show_next_content
  mark_engagement_completed
  @navigator.fetch_next_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

#show_next_providerObject

Seek and redirect to the next content provider in order.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/think_feel_do_engine/navigator_controller.rb', line 52

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



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

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