* fix: remove hardcoded paths * fix: use path helpers * swap href for link_to * feat: use path helpers * feat: use a data path to send through the path that we will be calling * feat: pass route through to js * dus index path * chore: change to use path_helpers * feat: update DUS controller * chore: oops remove these paths
208 lines
10 KiB
Text
208 lines
10 KiB
Text
<% title "[Moderate] #{@moderatable.title}" %>
|
||
|
||
<%= javascript_packs_with_chunks_tag "commentModPage", defer: true %>
|
||
|
||
<% cache(release_adjusted_cache_key("mod-styling")) do %>
|
||
<style>
|
||
<%= Rails.application.assets["moderators.css"].to_s.html_safe %>
|
||
</style>
|
||
<% end %>
|
||
|
||
<% if flash[:error].present? %>
|
||
<div class="crayons-banner crayons-banner--error" role="alert">
|
||
<%= flash[:error] %>
|
||
</div>
|
||
<% end %>
|
||
|
||
<div class="container mod-container" style="text-align: center">
|
||
<h2><a href="<%= @moderatable.path %>" rel="nofollow"><%= @moderatable.title %></a></h2>
|
||
<h3><a href="<%= @moderatable.user.path %>">@<%= @moderatable.user.username %></a></h3>
|
||
<% if @moderatable.class.name == "Article" &&
|
||
(Tag.where(requires_approval: true).pluck(:name) & @moderatable.decorate.cached_tag_list_array).any? &&
|
||
(current_user.any_admin? || @tag_moderator_tags.any? { |tag| @moderatable.tag_list.include?(tag.name) }) %>
|
||
<%= form_tag "/article_approvals", method: "post" do %>
|
||
<%= hidden_field_tag(:id, @moderatable.id) %>
|
||
<% if @moderatable.approved %>
|
||
<%= hidden_field_tag(:approved, false) %>
|
||
<button class="crayons-btn crayons-btn--secondary approval-button approval-removal">Remove approval</button>
|
||
<% else %>
|
||
<%= hidden_field_tag(:approved, true) %>
|
||
<button class="crayons-btn approval-button">Mark as approved</button>
|
||
<% end %>
|
||
<% end %>
|
||
<hr />
|
||
<% end %>
|
||
|
||
<div style="display: flex; justify-content: space-around;">
|
||
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "thumbsup") ? "reacted" : "" %>"
|
||
data-reactable-id="<%= @moderatable.id %>"
|
||
data-category="thumbsup"
|
||
data-reactable-type="<%= @moderatable.class.name %>">
|
||
<div class="reaction-button-circle">
|
||
<%= image_tag("emoji/emoji-one-thumbs-up-gray.png", alt: "Thumbs up emoji", class: "emoji-grey") %>
|
||
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-thumbs-up.png") %>" alt="Thumbs up emoji" />
|
||
<%= inline_svg_tag("checkmark.svg", aria: true, class: "crayons-icon reaction-checkmark", title: "Checkmark") %>
|
||
</div>
|
||
<span class="vote-text">High Quality</span>
|
||
</button>
|
||
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "thumbsdown") ? "reacted" : "" %>"
|
||
data-reactable-id="<%= @moderatable.id %>"
|
||
data-category="thumbsdown"
|
||
data-reactable-type="<%= @moderatable.class.name %>">
|
||
<div class="reaction-button-circle">
|
||
<%= image_tag("emoji/emoji-one-thumbs-down-gray.png", alt: "Thumbs down emoji", class: "emoji-grey") %>
|
||
<img class="reacted-emoji downvote" src="<%= asset_path("emoji/emoji-one-thumbs-down.png") %>" alt="Thumbs down emoji" />
|
||
<%= inline_svg_tag("checkmark.svg", aria: true, class: "crayons-icon reaction-checkmark", title: "Checkmark") %>
|
||
</div>
|
||
<span class="vote-text">Low Quality</span>
|
||
</button>
|
||
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "vomit") ? "reacted" : "" %>"
|
||
data-reactable-id="<%= @moderatable.id %>"
|
||
data-category="vomit"
|
||
data-reactable-type="<%= @moderatable.class.name %>">
|
||
<div class="reaction-button-circle">
|
||
<%= image_tag("emoji/emoji-one-nausea-face-gray.png", alt: "Nausea face emoji", class: "emoji-grey") %>
|
||
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-nausea-face.png") %>" alt="Nausea down emoji" />
|
||
<%= inline_svg_tag("checkmark.svg", aria: true, class: "crayons-icon reaction-checkmark", title: "Checkmark") %>
|
||
</div>
|
||
<span class="vote-text">Flag to Admins</span>
|
||
</button>
|
||
</div>
|
||
|
||
<% if current_user.has_role?(:super_admin) && @moderatable.class.name == "Article" %>
|
||
<h3> <a href="<%= @moderatable.path %>/edit">Edit Post</a> |
|
||
<a href="/resource_admin/articles/<%= @moderatable.id %>" data-no-instant>ResourceAdmin:Article</a> |
|
||
<a href="<%= admin_article_path(@moderatable.id) %>" data-no-instant>Admin:Article</a></h3>
|
||
<% elsif current_user.has_role?(:super_admin) && @moderatable.class.name == "Comment" %>
|
||
<h3> <a href="/admin/comments/<%= @moderatable.id %>" data-no-instant>Admin:Comment</a> |
|
||
<a href="<%= admin_user_path(@moderatable.user_id) %>" data-no-instant>Admin:User</a></h3>
|
||
<% end %>
|
||
<p>
|
||
<b style="font-size:1em">All negative reactions are private.</b>
|
||
</p>
|
||
<p>
|
||
Use <b>High Quality</b> to move this content "up" for any reason (quality, usefulness, etc.).
|
||
<br />
|
||
Use <b>Low Quality</b> to move this content "down" for any reason (quality, usefulness, etc.).
|
||
<br />
|
||
Use <b>Flag to Admins</b> for code of conduct violations (harassment, being a jerk, spam, etc.).
|
||
</p>
|
||
<div class="tag-mod-form" style="display: flex; flex-direction: column; align-items: center;">
|
||
<h2>Flag <a href="<%= @moderatable.user.path %>"><%= @moderatable.user.username %></a> as Abusive</h2>
|
||
<button class="reaction-button <%= Reaction.cached_any_reactions_for?(@moderatable, current_user, "vomit") ? "reacted" : "" %>"
|
||
data-reactable-id="<%= @moderatable.user.id %>"
|
||
data-category="vomit"
|
||
data-reactable-type="<%= @moderatable.user.class.name %>">
|
||
<div class="reaction-button-circle">
|
||
<%= image_tag("emoji/emoji-one-nausea-face-gray.png", alt: "Nausea face emoji", class: "emoji-grey") %>
|
||
<img class="reacted-emoji" src="<%= asset_path("emoji/emoji-one-nausea-face.png") %>" alt="Nausea down emoji" />
|
||
<%= inline_svg_tag("checkmark.svg", aria: true, class: "crayons-icon reaction-checkmark", title: "Checkmark") %>
|
||
</div>
|
||
<span class="vote-text">Flag User</span>
|
||
</button>
|
||
<p>
|
||
This is the equivalent of vomiting on <b>all</b> of this user's articles and will lower their article scores.
|
||
</p>
|
||
</div>
|
||
<% if current_user.any_admin? && @moderatable.class.name == "Comment" && !@moderatable.deleted %>
|
||
<div class="crayons-card crayons-card--secondary p-4 flex items-center">
|
||
<div class="fw-medium flex-1" style="text-align: left;">
|
||
<p class="fw-bold fs-xl">Delete This Comment</p>
|
||
</div>
|
||
<div class="flex">
|
||
<%= button_to "Delete Comment", comment_admin_delete_path(@moderatable.id), method: :patch, class: "crayons-btn crayons-btn--secondary ml-2" %>
|
||
</div>
|
||
</div>
|
||
<% end %>
|
||
<% if @hidden_comments.present? %>
|
||
<div class="tag-mod-form">
|
||
<h2>Hidden Comments</h2>
|
||
<form>
|
||
<ul id="hidden-comments">
|
||
<% @hidden_comments.each do |comment| %>
|
||
<li>
|
||
<a href="<%= comment.path %>">Comment by <%= comment.user.username %></a>
|
||
</li>
|
||
<% end %>
|
||
</ul>
|
||
</form>
|
||
</div>
|
||
<% end %>
|
||
<% if @allowed_to_adjust %>
|
||
<div class="tag-mod-form">
|
||
<h2>Tag Adjustments</h2>
|
||
<%= form_for(@tag_adjustment) do |f| %>
|
||
<b>Current live tags:</b> <%= @moderatable.tag_list %><br>
|
||
<% if @tag_adjustment.errors.any? %>
|
||
<div id="error_explanation">
|
||
<h2><%= pluralize(@tag_adjustment.errors.count, "error") %> prohibited this block from being saved:</h2>
|
||
<ul>
|
||
<% @tag_adjustment.errors.full_messages.each do |message| %>
|
||
<li><%= message %></li>
|
||
<% end %>
|
||
</ul>
|
||
</div>
|
||
<% end %>
|
||
<%= f.hidden_field :article_id, value: @moderatable.id %>
|
||
<% if current_user.any_admin? || @tag_moderator_tags.any? { |tag| @moderatable.tag_list.include?(tag.name) } %>
|
||
<div class="tag-mod-addition-radio">
|
||
<%= f.radio_button :adjustment_type, "removal", required: true %>
|
||
<%= f.label :adjustment_type, "Remove", value: "removal" %>
|
||
</div>
|
||
<% end %>
|
||
<% if @moderatable.tag_list.size < 4 %>
|
||
<div class="tag-mod-addition-radio">
|
||
<%= f.radio_button :adjustment_type, "addition", required: true %>
|
||
<%= f.label :adjustment_type, "Add", value: "addition" %>
|
||
</div>
|
||
<% end %>
|
||
<% if current_user.has_role?(:super_admin) %>
|
||
<%= f.text_field :tag_name, placeholder: "Tag Name", required: true %>
|
||
<% else %>
|
||
<%= f.select :tag_name, @tag_moderator_tags, { prompt: "Select Tag" }, required: true %>
|
||
<% end %>
|
||
<%= f.text_area :reason_for_adjustment, placeholder: "Reason for adjustment (Be super kind) - Only the reason is needed, the notification will take care of the rest.", required: true %>
|
||
<%= f.submit "Submit Tag Adjustment" %>
|
||
<% end %>
|
||
<% if @adjustments.present? %>
|
||
<% @adjustments.each do |adjustment| %>
|
||
<% if current_user.any_admin? || adjustment.user_id == current_user.id %>
|
||
<%= form_for(adjustment, url: "/tag_adjustments/#{adjustment.id}", html: { method: :delete, onsubmit: "return confirm('Are you sure you want to undo the #{adjustment.adjustment_type} of the #{adjustment.tag_name} tag?')" }) do |f| %>
|
||
<b><%= adjustment.adjustment_type == "removal" ? "Currently removed tag" : "Currently added tag" %>:</b> <%= adjustment.tag_name %>
|
||
<%= f.submit "×", id: "undo" %>
|
||
<% end %>
|
||
<% end %>
|
||
<% end %>
|
||
<% end %>
|
||
</div>
|
||
<% end %>
|
||
|
||
<% if @moderatable.class.name == "Article" %>
|
||
<div class="tag-mod-form">
|
||
<% @rating_vote = RatingVote.where(article_id: @moderatable.id, user_id: current_user.id).first %>
|
||
<% rating_hash = { "Novice" => 1, "Beginner" => 2, "Mid-level" => 3, "Advanced" => 4, "Expert" => 5 } %>
|
||
|
||
<h2>Experience Level of Post</h2>
|
||
|
||
<% rating_hash.each do |rating_name, rating_level| %>
|
||
<button
|
||
value="<%= rating_level %>"
|
||
name="rating_vote_<%= rating_level %>"
|
||
id="js__rating__vote__<%= rating_level %>"
|
||
class="level-rating-button article-mod-page <%= "selected" if @rating_vote&.rating.to_d == rating_level.to_d %>"
|
||
data-user-id="<%= current_user.id %>"
|
||
data-article-id="<%= @moderatable.id %>"
|
||
data-group="experience_level"
|
||
style="margin: 0.5rem 0;">
|
||
<div class="level-rating-content">
|
||
<span class="level-rating-number"><%= rating_level %> - </span>
|
||
<span class="level-rating-text"><%= rating_name %></span>
|
||
</div>
|
||
</button>
|
||
<% end %>
|
||
<p>
|
||
Who <em>might</em> find this post most valuable, based on overall experience level?
|
||
</p>
|
||
</div>
|
||
<% end %>
|
||
</div>
|