Class: ContentProviders::AwakePeriodForm

Inherits:
BitCore::ContentProvider
  • Object
show all
Defined in:
app/models/content_providers/awake_period_form.rb

Overview

Provides a form for a Participant to enter the most recent AwakePeriod.

Instance Method Summary collapse

Instance Method Details

#data_attributesObject



34
35
36
# File 'app/models/content_providers/awake_period_form.rb', line 34

def data_attributes
  [:start_time, :end_time]
end

#data_class_nameObject



30
31
32
# File 'app/models/content_providers/awake_period_form.rb', line 30

def data_class_name
  "AwakePeriod"
end

#render_current(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/content_providers/awake_period_form.rb', line 5

def render_current(options)
  participant = options.view_context.current_participant

  if participant.unfinished_awake_periods.exists?
    options.view_context.render(
      template: "think_feel_do_engine/awake_periods/incomplete",
      locals: {
        participant: participant
      }
    )
  else
    last_awake_time = participant.awake_periods.order("start_time").last
    options.view_context.render(
      template: "think_feel_do_engine/awake_periods/new",
      locals: {
        awake_period: participant.awake_periods.build,
        create_path: options.view_context.participant_data_path,
        participant: participant,
        wake_up_range: wake_up_range(last_awake_time),
        go_to_sleep_range: go_to_sleep_range(last_awake_time)
      }
    )
  end
end

#show_nav_link?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/content_providers/awake_period_form.rb', line 38

def show_nav_link?
  false
end