forum: change BUR counts to status labels.
Use pending / approved / rejected status labels in front of the topic title instead of a BUR count column. This is to make the forum listing easier to visually scan for resolved vs unresolved topics. Labels are only added for topics in the Tags category. This is a hack to avoid labels on megathreads that have had BURs mistakenly attached to them. [APPROVED] and [REJECTED] labels are stripped from thread titles to make the titles cleaner. This is a hack until these titles can be fixed.
This commit is contained in:
@@ -11,11 +11,13 @@ module ForumTopicsHelper
|
||||
!read_forum_topics.map(&:id).include?(topic.id)
|
||||
end
|
||||
|
||||
def bulk_update_request_counts(topic)
|
||||
requests = []
|
||||
requests << %(<span class="topic-pending-burs">Pending: #{topic.pending_bur_count}</span>) if topic.pending_bur_count.positive?
|
||||
requests << %(<span class="topic-approved-burs">Approved: #{topic.approved_bur_count}</span>) if topic.approved_bur_count.positive?
|
||||
requests << %(<span class="topic-rejected-burs">Rejected: #{topic.rejected_bur_count}</span>) if topic.rejected_bur_count.positive?
|
||||
requests.join(" | ").html_safe
|
||||
def forum_topic_status(topic)
|
||||
if topic.bulk_update_requests.any?(&:is_pending?)
|
||||
:pending
|
||||
elsif topic.category_name == "Tags" && topic.bulk_update_requests.all?(&:is_approved?)
|
||||
:approved
|
||||
elsif topic.category_name == "Tags" && topic.bulk_update_requests.all?(&:is_rejected?)
|
||||
:rejected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,6 +62,9 @@
|
||||
--forum-vote-meh-color: goldenrod;
|
||||
--forum-vote-down-color: red;
|
||||
--forum-topic-status-new-color: red;
|
||||
--forum-topic-status-pending-color: red;
|
||||
--forum-topic-status-approved-color: green;
|
||||
--forum-topic-status-rejected-color: green;
|
||||
|
||||
--moderation-report-text-color: red;
|
||||
--moderation-report-border: 2px solid red;
|
||||
@@ -325,6 +328,9 @@ body[data-current-user-theme="dark"] {
|
||||
--forum-vote-meh-color: var(--yellow-1);
|
||||
--forum-vote-down-color: var(--red-1);
|
||||
--forum-topic-status-new-color: var(--red-1);
|
||||
--forum-topic-status-pending-color: var(--red-1);
|
||||
--forum-topic-status-approved-color: var(--green-1);
|
||||
--forum-topic-status-rejected-color: var(--green-1);
|
||||
|
||||
--moderation-report-text-color: var(--red-1);
|
||||
--moderation-report-border: 2px solid var(--red-1);
|
||||
|
||||
@@ -57,6 +57,18 @@ div#c-forum-topics {
|
||||
&.new {
|
||||
color: var(--forum-topic-status-new-color);
|
||||
}
|
||||
|
||||
&.pending {
|
||||
color: var(--forum-topic-status-pending-color);
|
||||
}
|
||||
|
||||
&.approved {
|
||||
color: var(--forum-topic-status-approved-color);
|
||||
}
|
||||
|
||||
&.rejected {
|
||||
color: var(--forum-topic-status-rejected-color);
|
||||
}
|
||||
}
|
||||
|
||||
#a-index {
|
||||
|
||||
@@ -163,16 +163,8 @@ class ForumTopic < ApplicationRecord
|
||||
original_post&.update_columns(:updater_id => updater.id, :updated_at => Time.now)
|
||||
end
|
||||
|
||||
def pending_bur_count
|
||||
bulk_update_requests.select {|request| request.status == "pending"}.size
|
||||
end
|
||||
|
||||
def approved_bur_count
|
||||
bulk_update_requests.select {|request| request.status == "approved"}.size
|
||||
end
|
||||
|
||||
def rejected_bur_count
|
||||
bulk_update_requests.select {|request| request.status == "rejected"}.size
|
||||
def pretty_title
|
||||
title.gsub(/\A\[APPROVED\]|\[REJECTED\]/, "")
|
||||
end
|
||||
|
||||
def self.available_includes
|
||||
|
||||
@@ -28,15 +28,18 @@
|
||||
<span class="topic-status label new">New</span>
|
||||
<% end %>
|
||||
|
||||
<%= link_to topic.title, forum_topic_path(topic), class: "forum-post-link" %>
|
||||
<% status = forum_topic_status(topic) %>
|
||||
<% if status.present? %>
|
||||
<span class="topic-status label <%= status %>"><%= status %></span>
|
||||
<%= link_to topic.pretty_title, forum_topic_path(topic), class: "forum-post-link" %>
|
||||
<% else %>
|
||||
<%= link_to topic.title, forum_topic_path(topic), class: "forum-post-link" %>
|
||||
<% end %>
|
||||
|
||||
<% if topic.response_count > Danbooru.config.posts_per_page %>
|
||||
<%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% t.column "BURs", width: "20%" do |topic| %>
|
||||
<%= bulk_update_request_counts(topic) %>
|
||||
<% end %>
|
||||
<% t.column "Creator", width: "8%" do |topic| %>
|
||||
<%= link_to_user topic.creator %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user