Module: ThinkFeelDoEngine::Coach::GroupDashboardHelper

Defined in:
app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb

Overview

Displays navigational information in the form of breadcrumbs

Instance Method Summary collapse

Instance Method Details

#activity_status(activity) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 115

def activity_status(activity)
  if activity.monitored?
    "monitored"
  elsif activity.planned?
    "planned"
  elsif activity.reviewed_and_complete?
    "reviewed and complete"
  elsif activity.reviewed_and_incomplete?
    "reviewed and incomplete"
  end
end

#comment_count(shared_item) ⇒ Object



27
28
29
30
31
32
33
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 27

def comment_count(shared_item)
  comment_count = 0
  SocialNetworking::SharedItem.where(item: shared_item).each do |item|
    comment_count += SocialNetworking::Comment.where(item: item).count
  end
  comment_count
end

#comment_item_description(comment) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 47

def comment_item_description(comment)
  case comment.item_type
  when "SocialNetworking::OnTheMindStatement"
    "OnTheMindStatement: "\
    "#{SocialNetworking::
        OnTheMindStatement.find(comment.item_id).description}"
  when "SocialNetworking::SharedItem"
    comment_shared_item_description(comment)
  else
    "Unknown Item Type, Item ID:#{comment.item_id},"\
    " Item Type: #{comment.item_type}"
  end
end

#comment_shared_item_description(comment) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 79

def comment_shared_item_description(comment)
  if comment.item
    case comment.item.item_type
    when "Activity"
      activity = Activity.find(comment.item.item_id)
      "Activity: #{activity.participant.study_id},"\
        " #{activity.activity_type.title}, #{comment.item.action_type}"
    when "SocialNetworking::Profile"
      "ProfileCreation: #{comment.participant.study_id}"
    when "SocialNetworking::Goal"
      goal = SocialNetworking::Goal.find(comment.item.item_id)
      "Goal: #{goal.participant.study_id}, #{goal.description}"
    when "Thought"
      thought = Thought.find(comment.item.item_id)
      "Thought: #{thought.participant.study_id}, #{thought.description}"
    else
      "Unknown SharedItem Type, Item ID:#{comment.item_id},"\
      " Item Type: #{comment.item_type}"
    end
  else
    "Comment was made for an unknown item."
  end
end

#day_in_study(date, membership) ⇒ Object



43
44
45
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 43

def day_in_study(date, membership)
  date.to_date - membership.start_date + 1
end

#goal_like_count(goal) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 131

def goal_like_count(goal)
  like_total = 0
  goal_shared_items =
    SocialNetworking::SharedItem
    .where(item_type: "SocialNetworking::Goal", item_id: goal.id)
  goal_shared_items.each do |item|
    like_total +=
      SocialNetworking::Like
      .where(item_type: "SocialNetworking::SharedItem",
             item_id: item.id).count
  end
  like_total
end

#like_count(shared_item) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 19

def like_count(shared_item)
  like_count = 0
  SocialNetworking::SharedItem.where(item: shared_item).each do |item|
    like_count += SocialNetworking::Like.where(item: item).count
  end
  like_count
end

#list_participant_names(group, participants) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 67

def list_participant_names(group, participants)
  participant_list = "<ul>"
  participants.each do |participant|
    participant_list +=
    "<li>#{link_to participant.display_name,
                   coach_group_patient_dashboard_path(
                     group, participant)}</li>" if participant
  end
  participant_list += "</ul>"
  participant_list
end

#membership_comments(membership) ⇒ Object



107
108
109
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 107

def membership_comments(membership)
  SocialNetworking::Comment.where(participant: membership.participant)
end

#membership_goals(membership) ⇒ Object



103
104
105
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 103

def membership_goals(membership)
  SocialNetworking::Goal.where(participant: membership.participant)
end

#membership_likes(membership) ⇒ Object



111
112
113
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 111

def membership_likes(membership)
  SocialNetworking::Like.where(participant: membership.participant)
end

#not_nil_and_populated_string(string_to_check) ⇒ Object



127
128
129
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 127

def not_nil_and_populated_string(string_to_check)
  string_to_check && !string_to_check.empty?
end

#participants_that_read_lesson(task) ⇒ Object



61
62
63
64
65
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 61

def participants_that_read_lesson(task)
  render partial: "think_feel_do_engine/coach/group_dashboard/"\
                  "lesson_completion_breakdown",
         locals: { task: task }
end

#social_likes_and_comments_column_headersObject



5
6
7
8
9
10
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 5

def social_likes_and_comments_column_headers
  if social_features?
    (:th, "Likes") +
      (:th, "Comments")
  end
end

#social_likes_and_comments_count_rows(shared_item) ⇒ Object



12
13
14
15
16
17
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 12

def social_likes_and_comments_count_rows(shared_item)
  if social_features?
    (:td, like_count(shared_item)) +
      (:td, comment_count(shared_item))
  end
end

#week_in_study(date, membership) ⇒ Object



35
36
37
38
39
40
41
# File 'app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb', line 35

def week_in_study(date, membership)
  if (day_in_study(date, membership) / 7.0).ceil == 0
    1
  else
    (day_in_study(date, membership) / 7.0).ceil
  end
end