Sha256: 909390ab73da9838332bed7e31fbd2b22bbea6ccdd77ef80cb81b273de5b6672
Contents?: true
Size: 1.4 KB
Versions: 13
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module ContentProviders # Provides multiple forms for a Participant to enter past Activities. class PastActivityForm < BitCore::ContentProvider def render_current(options) participant = options.view_context.current_participant options.view_context.render( template: "think_feel_do_engine/activities/past_activity_form", locals: { timestamps: timestamps(participant), activity: participant.activities.build, create_path: options.view_context.participant_data_path } ) end def data_attributes [ :start_time, :end_time, :activity_type_title, :actual_pleasure_intensity, :actual_accomplishment_intensity ] end def data_class_name "Activity" end def show_nav_link? false end private def most_recent_awake_period(participant) if participant.unfinished_awake_periods.exists? participant.most_recent_unfinished_awake_period else participant.awake_periods.last end end def timestamps(participant) period = most_recent_awake_period(participant) start_time = period.start_time end_time = period.end_time times = [] (start_time.to_i..(end_time.to_i - 1.hour)).step(1.hour) do |timestamp| times << timestamp end times end end end
Version data entries
13 entries across 13 versions & 1 rubygems