Skip to content

Commit d58588c

Browse files
committed
Add absolute time info as hover over of elapsed time text
This commit adds the support to show the absolute time when the user moves the mouse cursor over an elapsed time text that is present in the topics list, or in each message header. Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
1 parent 02daf4e commit d58588c

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

app/helpers/application_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def smart_time_display(time)
1818
end
1919
end
2020

21+
def absolute_time_display(time)
22+
return "" if time.nil?
23+
time.strftime("%B %d, %Y at %I:%M %p")
24+
end
25+
2126
def render_message_body(body)
2227
QuotedEmailFormatter.new(body.to_s).to_html.html_safe
2328
end

app/views/activities/index.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.activity-card class=("is-unread" if activity.read_at.nil?)
1717
.activity-meta
1818
span.activity-type = activity.activity_type.humanize
19-
span.activity-time = smart_time_display(activity.created_at)
19+
span.activity-time title=absolute_time_display(activity.created_at) = smart_time_display(activity.created_at)
2020
- if activity.read_at.nil?
2121
span.activity-unread-badge Unread
2222

app/views/topics/_message.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
.author-email = message.sender.email
2020
.message-meta
2121
.message-date
22-
time datetime=message.created_at.iso8601 title=message.created_at.strftime("%B %d, %Y at %I:%M %p")
22+
time datetime=message.created_at.iso8601 title=absolute_time_display(message.created_at)
2323
= time_ago_in_words(message.created_at)
2424
| ago
2525
- if message.reply_to

app/views/topics/_topics.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- last_message = topic.messages.order(:created_at).last
1717
.activity-info
1818
.activity-replies = "#{topic.messages.count - 1} replies"
19-
.activity-time = smart_time_display(last_message.created_at)
19+
.activity-time title=absolute_time_display(last_message.created_at) = smart_time_display(last_message.created_at)
2020
- if user_signed_in?
2121
- state = @topic_states&.dig(topic.id) || {}
2222
- status = state[:status]

app/views/topics/_topics_page.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
.topic-column.activity-col
3333
- last_message = topic.messages.order(:created_at).last
3434
.activity-info
35-
.activity-time = time_ago_in_words(last_message.created_at) + " ago"
35+
.activity-time title=absolute_time_display(last_message.created_at) = time_ago_in_words(last_message.created_at) + " ago"
3636
small.activity-author by #{last_message.sender.name}
3737

3838
/ Next page Turbo Frame for infinite scroll

0 commit comments

Comments
 (0)