File tree Expand file tree Collapse file tree 4 files changed +73
-2
lines changed
assets/stylesheets/components Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Original file line number Diff line number Diff line change 5757 text-decoration : underline;
5858 }
5959}
60+
61+ .sidebar .attachments-list {
62+ list-style : none;
63+ padding-left : 0 ;
64+ margin : var (--spacing-3 ) 0 ;
65+ }
66+
67+ .sidebar .attachments-list li + li {
68+ margin-top : var (--spacing-2 );
69+ }
70+
71+ .sidebar .attachment-link {
72+ display : flex;
73+ justify-content : space-between;
74+ gap : var (--spacing-2 );
75+ color : var (--color-text-link );
76+ text-decoration : none;
77+ font-weight : var (--font-weight-medium );
78+ }
79+
80+ .sidebar .attachment-link : hover {
81+ text-decoration : underline;
82+ }
83+
84+ .sidebar .attachment-target {
85+ font-weight : var (--font-weight-bold );
86+ }
87+
88+ .sidebar .attachment-date {
89+ color : var (--color-text-secondary );
90+ font-size : var (--font-size-sm );
91+ }
92+
93+ .sidebar .attachment-name {
94+ display : block;
95+ padding-left : var (--spacing-4 );
96+ margin-top : var (--spacing-1 );
97+ }
98+
99+ .sidebar .attachment-more {
100+ display : block;
101+ padding-left : var (--spacing-4 );
102+ color : var (--color-text-secondary );
103+ font-size : var (--font-size-sm );
104+ margin-top : var (--spacing-1 );
105+ }
106+
107+ .sidebar .attachment-names {
108+ color : var (--color-text-secondary );
109+ }
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def new_topics_count
3333 end
3434
3535 def show
36- messages_scope = @topic . messages . includes ( :sender , reply_to : :sender )
36+ messages_scope = @topic . messages . includes ( :sender , { reply_to : :sender } , :attachments )
3737
3838 @messages = messages_scope . order ( created_at : :asc )
3939 @message_numbers = @messages . each_with_index . to_h { |msg , idx | [ msg . id , idx + 1 ] }
Original file line number Diff line number Diff line change 3838 = render_message_body(message.body)
3939
4040 - if message.attachments.any?
41- .message-attachments
41+ .message-attachments id = " message-#{message.id}-attachments "
4242 h4 Attachments:
4343 - message.attachments.each do |attachment |
4444 - if attachment.patch?
Original file line number Diff line number Diff line change 1515 - else
1616 p No participants yet
1717
18+ - attachment_messages = @messages .select { |msg | msg.attachments.any? }
19+ details .sidebar-section open =true
20+ summary .sidebar-heading Attachments
21+ .sidebar-section
22+ - if attachment_messages.any?
23+ ul .attachments-list
24+ - attachment_messages.sort_by(& :created_at ).reverse_each do |msg |
25+ - number = @message_numbers [msg.id]
26+ li
27+ = link_to " #message-#{ msg.id } -attachments" , class : " attachment-link" do
28+ span .attachment-target = " ##{ number } "
29+ span .attachment-date = smart_time_display(msg.created_at)
30+ - names = msg.attachments.map(& :file_name )
31+ - names.first(2 ).each do |name |
32+ .attachment-name = name
33+ - if names.size > 2
34+ .attachment-more = " + #{ names.size - 2 } more"
35+ - else
36+ p No attachments in this thread
37+
38+
1839 details .sidebar-section open =true
1940 summary .sidebar-heading Thread Outline
2041 - if @thread_outline .present?
You can’t perform that action at this time.
0 commit comments