modqueue: move score highlighting from js to presenter.

The 'post-has-children' class was dropped because it was unused
('post-status-has-children' is already added elsewhere).
This commit is contained in:
evazion
2018-11-06 10:36:46 -06:00
parent 2eb284f31e
commit 26c1eadf6a
3 changed files with 5 additions and 24 deletions

View File

@@ -14,22 +14,6 @@ ModQueue.increment_processed = function() {
}
}
ModQueue.initialize_hilights = function() {
$.each($("div.post"), function(i, v) {
var $post = $(v);
var score = parseInt($post.data("score"));
if (score >= 3) {
$post.addClass("post-pos-score");
}
if (score <= -3) {
$post.addClass("post-neg-score");
}
if ($post.data("has-children")) {
$post.addClass("post-has-children");
}
});
}
ModQueue.detailed_rejection_dialog = function() {
$("#post_disapproval_post_id").val($(this).data("post-id"));
$("#detailed-rejection-dialog").find("form")[0].reset();
@@ -40,11 +24,6 @@ ModQueue.detailed_rejection_dialog = function() {
$(function() {
$(window).on("danbooru:modqueue_increment_processed", ModQueue.increment_processed);
if ($("#c-moderator-post-queues").length) {
ModQueue.initialize_hilights();
}
$(document).on("click.danbooru", ".quick-mod .detailed-rejection-link", ModQueue.detailed_rejection_dialog);
});

View File

@@ -81,15 +81,17 @@ class PostPresenter < Presenter
ApplicationController.render(partial: "posts/partials/index/preview", locals: locals)
end
def self.preview_class(post, options = {})
def self.preview_class(post, highlight_score: nil, pooled: nil, size: nil, similarity: nil, **options)
klass = ["post-preview"]
# klass << " large-cropped" if post.has_cropped? && options[:show_cropped]
klass << "captioned" if options.values_at(:pooled, :size, :similarity).any?(&:present?)
klass << "captioned" if pooled || size || similarity
klass << "post-status-pending" if post.is_pending?
klass << "post-status-flagged" if post.is_flagged?
klass << "post-status-deleted" if post.is_deleted?
klass << "post-status-has-parent" if post.parent_id
klass << "post-status-has-children" if post.has_visible_children?
klass << "post-pos-score" if highlight_score && post.score >= 3
klass << "post-neg-score" if highlight_score && post.score <= -3
klass
end

View File

@@ -1,4 +1,4 @@
<%= content_tag(:div, { id: "post-#{post.id}", class: ["post", "mod-queue-preview", *PostPresenter.preview_class(post)].join(" ") }.merge(PostPresenter.data_attributes(post))) do %>
<%= content_tag(:div, { id: "post-#{post.id}", class: ["post", "mod-queue-preview", *PostPresenter.preview_class(post, highlight_score: true)].join(" ") }.merge(PostPresenter.data_attributes(post))) do %>
<aside>
<%= link_to(image_tag(post.preview_file_url), post_path(post), :target => "_blank") %>
</aside>