forked from hackorum-dev/hackorum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_topics.html.slim
More file actions
56 lines (56 loc) · 2.85 KB
/
_topics.html.slim
File metadata and controls
56 lines (56 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
- topics.each do |topic|
tr.topic-row data-topic-id=topic.id data-last-message-id=topic.messages.maximum(:id)
td.topic-title data-label="Topic"
- if topic.has_contributor_activity?
div class ="topic-icon activity-#{ topic.highest_contributor_activity }"
i.fa-solid.fa-users-rays
- if topic.attachments.exists?
.topic-icon
i.fa-solid.fa-paperclip
= link_to topic.title, topic_path(topic), class: "topic-link"
td.topic-participants data-label="Participants"
- participants = topic.participant_aliases(limit: 10)
- participant_count = topic.participant_count
= render partial: "avatar_list", locals: { participants: participants, total_participants: participant_count }
td.topic-activity data-label="Replies / Activity"
- last_message = topic.messages.order(:created_at).last
.activity-info
.activity-replies = "#{topic.messages.count - 1} replies"
.activity-time title=absolute_time_display(last_message.created_at) = smart_time_display(last_message.created_at)
- if user_signed_in?
- state = @topic_states&.dig(topic.id) || {}
- status = state[:status]
- progress = state[:progress]
- team_readers = state[:team_readers] || []
- filtered_readers = team_readers
- if params[:team_id].present?
- filtered_readers = team_readers.select { |r| r[:team_ids]&.include?(params[:team_id].to_i) }
td.topic-status data-label="Status"
- case status
- when :read
span.status-pill.is-read title="Read"
span.status-shape 100
- when :reading
- pct = ((progress || 0) * 100).round
span.status-pill.is-reading title="Reading"
span.status-shape = "#{pct}%"
- when :aware
span.status-pill.is-aware title="Aware"
span.status-shape
- else
span.status-pill.is-new title="New"
span.status-shape !
- note_count = user_signed_in? ? @topic_note_counts&.dig(topic.id).to_i : 0
- if note_count.positive?
.note-status title="#{note_count} note(s) visible to you"
span.note-icon 📝
span.note-count = note_count
- if filtered_readers.any?
.team-reader-avatars
- filtered_readers.each do |reader|
- alias_record = reader[:user].primary_alias || reader[:user].aliases.first
- gravatar_name = alias_record&.name || "User ##{reader[:user].id}"
- next unless alias_record
- avatar_url = alias_record.gravatar_url(size: 20)
- title_text = "#{gravatar_name} (#{reader[:status]})"
= image_tag avatar_url, class: ["team-reader-avatar", ("is-read" if reader[:status] == :read), ("is-reading" if reader[:status] == :reading)].compact.join(" "), alt: alias_record.name, title: title_text