Class: WorkActivity::Renderer
- Inherits:
-
Object
- Object
- WorkActivity::Renderer
show all
- Defined in:
- app/models/work_activity.rb
Constant Summary
collapse
- UNKNOWN_USER =
"Unknown user outside the system"
- DATE_TIME_FORMAT =
"%B %d, %Y %H:%M"
- DATE_FORMAT =
"%B %d, %Y"
- SORTABLE_DATE_TIME_FORMAT =
"%Y-%m-%d %H:%M"
Instance Method Summary
collapse
Constructor Details
#initialize(work_activity) ⇒ Renderer
Returns a new instance of Renderer.
116
117
118
|
# File 'app/models/work_activity.rb', line 116
def initialize(work_activity)
@work_activity = work_activity
end
|
Instance Method Details
#created_by_user_html ⇒ Object
129
130
131
132
133
|
# File 'app/models/work_activity.rb', line 129
def created_by_user_html
return UNKNOWN_USER unless @work_activity.created_by_user
"#{@work_activity.created_by_user.given_name_safe} (@#{@work_activity.created_by_user.uid})"
end
|
#created_sortable_html ⇒ Object
135
136
137
|
# File 'app/models/work_activity.rb', line 135
def created_sortable_html
@work_activity.created_at.time.strftime(SORTABLE_DATE_TIME_FORMAT)
end
|
#created_updated_html ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
|
# File 'app/models/work_activity.rb', line 139
def created_updated_html
created = @work_activity.created_at.time.strftime(DATE_TIME_FORMAT)
updated = @work_activity.updated_at.time.strftime(DATE_TIME_FORMAT)
created_date = @work_activity.created_at.time.strftime(DATE_FORMAT)
updated_date = @work_activity.updated_at.time.strftime(DATE_FORMAT)
if created_date == updated_date
created
else
"#{created} (backdated event created #{updated})"
end
end
|
#title_html ⇒ Object
151
152
153
|
# File 'app/models/work_activity.rb', line 151
def title_html
"<span class='activity-history-title'>#{created_updated_html} by #{created_by_user_html}</span>"
end
|
#to_html ⇒ Object
125
126
127
|
# File 'app/models/work_activity.rb', line 125
def to_html
title_html + "<span class='message-html'>#{body_html.chomp}</span>"
end
|