Skip to content

Commit 77740f5

Browse files
committed
abstracted flags modal into a posts/_flags_modal partial
1 parent 0f86903 commit 77740f5

2 files changed

Lines changed: 39 additions & 23 deletions

File tree

app/views/posts/_expanded.html.erb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -351,29 +351,7 @@
351351
<% end %>
352352

353353
<% if current_user&.can_handle_flags? %>
354-
<div class="post--action-dialog js-flags">
355-
<div class="widget">
356-
<div class="widget--header">Flags on this post</div>
357-
<% post.flags.unhandled.each do |flag| %>
358-
<% next if !current_user.at_least_moderator? && (flag.post_flag_type.nil? || flag.post_flag_type.confidential) %>
359-
<% next if !current_user.at_least_moderator? && (current_user.id == flag.user.id) %>
360-
<div class="widget--body">
361-
<div>
362-
<p>
363-
<strong><%= flag.post_flag_type&.name || 'Flag reason' %>:</strong> <%= flag.reason %> &mdash;
364-
<%= user_link flag.user %>
365-
</p>
366-
<input class="form-element flag-resolve-comment has-float-left" style="max-width: 300px;" placeholder="Optional comment for flagger">
367-
<div class="has-float-right has-padding-1">
368-
<a href="#" class="flag-resolve button" data-result='helpful' data-flag-id="<%= flag.id %>">Helpful</a>
369-
<a href="#" class="flag-resolve button" data-result='declined' data-flag-id="<%= flag.id %>">Decline</a>
370-
</div>
371-
<div class="has-clear-clear"></div>
372-
</div>
373-
</div>
374-
<% end %>
375-
</div>
376-
</div>
354+
<%= render 'posts/flags_modal', post: post, user: current_user %>
377355
<% end %>
378356

379357
<% if is_top_level && post.children.undeleted.length >= SiteSetting["TableOfContentsThreshold"] && SiteSetting["TableOfContentsThreshold"] != -1 %>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<%#
2+
"Renders post flags modal
3+
4+
Variables:
5+
post : Post to render the modal for
6+
user : User that will handle the flags
7+
"%>
8+
9+
<div class="post--action-dialog js-flags">
10+
<div class="widget">
11+
<div class="widget--header">Flags on this post</div>
12+
<% Flag.accessible_to(user, post).unhandled.each do |flag| %>
13+
<% next if !user.at_least_moderator? && flag.user.same_as?(user) %>
14+
<div class="widget--body">
15+
<div>
16+
<p>
17+
<strong><%= flag.post_flag_type&.name || 'Flag reason' %>:</strong> <%= flag.reason %> &mdash;
18+
<%= user_link flag.user %>
19+
</p>
20+
<input class="form-element flag-resolve-comment has-float-left"
21+
style="max-width: 300px;"
22+
placeholder="Optional comment for flagger">
23+
<div class="has-float-right has-padding-1">
24+
<a href="#"
25+
class="flag-resolve button"
26+
data-result='helpful'
27+
data-flag-id="<%= flag.id %>">Helpful</a>
28+
<a href="#"
29+
class="flag-resolve button"
30+
data-result='declined'
31+
data-flag-id="<%= flag.id %>">Decline</a>
32+
</div>
33+
<div class="has-clear-clear"></div>
34+
</div>
35+
</div>
36+
<% end %>
37+
</div>
38+
</div>

0 commit comments

Comments
 (0)