From 3c1d007c5ebc5d1c294b642520f628400fa96cd6 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 10 May 2020 11:57:18 +0200 Subject: [PATCH] Fix lints in app/views/moderation --- app/views/moderation/_actions.html.haml | 4 +- app/views/moderation/_discussion.haml | 29 ++++++++++ app/views/moderation/_discussion.html.haml | 28 ---------- app/views/moderation/_moderationbox.haml | 55 +++++++++++++++++++ app/views/moderation/_moderationbox.html.haml | 46 ---------------- .../{_userbox.html.haml => _userbox.haml} | 10 ++-- 6 files changed, 92 insertions(+), 80 deletions(-) create mode 100644 app/views/moderation/_discussion.haml delete mode 100644 app/views/moderation/_discussion.html.haml create mode 100644 app/views/moderation/_moderationbox.haml delete mode 100644 app/views/moderation/_moderationbox.html.haml rename app/views/moderation/{_userbox.html.haml => _userbox.haml} (57%) diff --git a/app/views/moderation/_actions.html.haml b/app/views/moderation/_actions.html.haml index 20c21cd9..9bfeecb4 100644 --- a/app/views/moderation/_actions.html.haml +++ b/app/views/moderation/_actions.html.haml @@ -1,4 +1,4 @@ -%a.btn.btn-default.btn-block{href: moderation_priority_path(user.id)} +%a.btn.btn-default.btn-block{ href: moderation_priority_path(user.id) } View reports relating to user -%a.btn.btn-default.btn-block{href: moderation_ip_path(user.id)} +%a.btn.btn-default.btn-block{ href: moderation_ip_path(user.id) } View users with same IP diff --git a/app/views/moderation/_discussion.haml b/app/views/moderation/_discussion.haml new file mode 100644 index 00000000..86ebc108 --- /dev/null +++ b/app/views/moderation/_discussion.haml @@ -0,0 +1,29 @@ +- if report.moderation_comments.all.count.zero? + = t 'views.answerbox.no_comment' +- else + %ul.comment__container + - report.moderation_comments.order(:created_at).each do |comment| + %li.comment{ data: { comment_id: comment.id } } + .media + .pull-left + %img.comment__user-avatar.avatar-sm{ src: comment.user.profile_picture.url(:medium) } + .media-body + %h6.media-heading.comment__user + = user_screen_name comment.user + %span.text-muted{ title: comment.created_at, data: { toggle: :tooltip, placement: :right } } + = time_ago_in_words(comment.created_at) + ago + - if comment.user == current_user + .pull-right + .btn-group + %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } } + %span.caret + .dropdown-menu.dropdown-menu-right{ role: :menu } + %a.dropdown-item.text-danger{ href: '#', tabindex: -1, data: { action: 'mod-comment-destroy', id: comment.id } } + %i.fa.fa-trash-o + = t 'views.actions.delete' + .comment__content + = comment.content +.form-group.has-feedback{ name: 'mod-comment-new-group', data: { id: report.id } } + %input.form-control.comments--box{ type: :text, placeholder: t('views.placeholder.comment'), name: 'mod-comment-new', data: { id: report.id } } + %span.text-muted.form-control-feedback.comments--count{ id: "mod-comment-charcount-#{report.id}" } 160 diff --git a/app/views/moderation/_discussion.html.haml b/app/views/moderation/_discussion.html.haml deleted file mode 100644 index 4be392f0..00000000 --- a/app/views/moderation/_discussion.html.haml +++ /dev/null @@ -1,28 +0,0 @@ -- if report.moderation_comments.all.count == 0 - = t 'views.answerbox.no_comment' -- else - %ul.comment__container - - report.moderation_comments.order(:created_at).each do |comment| - %li.comment{data: { comment_id: comment.id }} - .media - .pull-left - %img.comment__user-avatar.avatar-sm{src: comment.user.profile_picture.url(:medium)} - .media-body - %h6.media-heading.comment__user - = user_screen_name comment.user - %span.text-muted{title: comment.created_at, data: { toggle: :tooltip, placement: :right }} - = "#{time_ago_in_words(comment.created_at)} ago" - - if comment.user == current_user - .pull-right - .btn-group - %button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} - %span.caret - .dropdown-menu.dropdown-menu-right{role: :menu} - %a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'mod-comment-destroy', id: comment.id }} - %i.fa.fa-trash-o - = t 'views.actions.delete' - .comment__content - = comment.content -.form-group.has-feedback{name: 'mod-comment-new-group', data: { id: report.id }} - %input.form-control.comments--box{type: :text, placeholder: t('views.placeholder.comment'), name: 'mod-comment-new', data: { id: report.id }} - %span.text-muted.form-control-feedback.comments--count{id: "mod-comment-charcount-#{report.id}"} 160 diff --git a/app/views/moderation/_moderationbox.haml b/app/views/moderation/_moderationbox.haml new file mode 100644 index 00000000..21eb0aa5 --- /dev/null +++ b/app/views/moderation/_moderationbox.haml @@ -0,0 +1,55 @@ +- unless report.nil? || report.target.nil? || report.user.nil? || report.type.nil? + .card.moderationbox{ data: { id: report.id } } + .card-header + %img.avatar-sm{ src: report.user.profile_picture.url(:medium) } + = raw t('views.moderation.moderationbox.reported', + user: user_screen_name(report.user), + content: report.type.sub('Reports::', ''), + time: time_tooltip(report)) + .card-body + %p + - if report.type == 'Reports::User' + = user_screen_name report.target + - else + = report.target.content + %p + %b= t 'views.moderation.moderationbox.reason' + %br + - if report.reason.nil? || report.reason.strip.blank? + No reason provided + - else + - report.reason.lines.each do |reason| + - next if reason.strip.blank? + = reason.strip + .row + .col-md-8.col-sm-8.col-xs-8.text-left + %a.btn.btn-primary{ href: content_url(report) } + = t('views.moderation.moderationbox.view', content: report.type.sub('Reports::', '')) + - if report.target.respond_to?(:user) && report.target.user + %a.btn.btn-primary{ href: show_user_profile_path(report.target.user.screen_name) } + = t('views.moderation.moderationbox.view', content: t('views.general.user')) + %a.btn.btn-primary{ href: moderation_priority_path(report.target.user.id) } + Reports + %a.btn.btn-primary{ href: moderation_ip_path(report.target.user.id) } + IP + .col-md-4.col-sm-4.col-xs-4.text-right + %span.mod-count{ id: "mod-count-#{report.id}" } + = report.votes + .btn-group + %button.btn.btn-success.btn-sm{ type: :button, + name: 'mod-vote', + disabled: current_user.report_x_voted?(report, true) ? 'disabled' : nil, + data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'upvote' } } + %i.fa.fa-thumbs-up + %button.btn.btn-danger.btn-sm{ type: :button, + name: 'mod-vote', + disabled: current_user.report_x_voted?(report, false) ? 'disabled' : nil, + data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'downvote' } } + %i.fa.fa-thumbs-down + %button.btn.btn-primary.btn-sm{ type: :button, name: 'mod-comments', data: { id: report.id, state: :hidden } } + %i.fa.fa-comments + %span{ id: "mod-comment-count-#{report.id}" }= report.moderation_comments.all.count + %button.btn.btn-default.btn-sm{ type: :button, name: 'mod-delete-report', data: { id: report.id } } + %i.fa.fa-trash-o + .card-footer{ id: "mod-comments-section-#{report.id}", style: 'display: none' } + %div{ id: "mod-comments-#{report.id}" }= render 'moderation/discussion', report: report diff --git a/app/views/moderation/_moderationbox.html.haml b/app/views/moderation/_moderationbox.html.haml deleted file mode 100644 index 122582cb..00000000 --- a/app/views/moderation/_moderationbox.html.haml +++ /dev/null @@ -1,46 +0,0 @@ -- unless report.nil? or report.target.nil? or report.user.nil? or report.type.nil? - .card.moderationbox{data: { id: report.id }} - .card-header - %img.avatar-sm{src: report.user.profile_picture.url(:medium)} - = raw t('views.moderation.moderationbox.reported', user: user_screen_name(report.user), content: report.type.sub('Reports::', ''), time: time_tooltip(report)) - .card-body - %p - - if report.type == 'Reports::User' - = user_screen_name report.target - - else - = report.target.content - %p - %b= t 'views.moderation.moderationbox.reason' - %br - - if report.reason.nil? or report.reason.strip.blank? - No reason provided - - else - - report.reason.lines.each do |reason| - - next if reason.strip.blank? - = reason.strip - .row - .col-md-8.col-sm-8.col-xs-8.text-left - %a.btn.btn-primary{href: content_url(report)} - = t('views.moderation.moderationbox.view', content: report.type.sub('Reports::', '')) - - if report.target.respond_to? :user and not report.target.user.nil? - %a.btn.btn-primary{href: show_user_profile_path(report.target.user.screen_name)} - = t('views.moderation.moderationbox.view', content: t('views.general.user')) - %a.btn.btn-primary{href: moderation_priority_path(report.target.user.id)} - Reports - %a.btn.btn-primary{href: moderation_ip_path(report.target.user.id)} - IP - .col-md-4.col-sm-4.col-xs-4.text-right - %span.mod-count{id: "mod-count-#{report.id}"} - = report.votes - .btn-group - %button.btn.btn-success.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, true) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'upvote' }} - %i.fa.fa-thumbs-up - %button.btn.btn-danger.btn-sm{type: :button, name: "mod-vote", disabled: current_user.report_x_voted?(report, false) ? 'disabled' : nil, data: { id: report.id, action: current_user.report_voted?(report) ? 'unvote' : 'vote', vote_type: 'downvote' }} - %i.fa.fa-thumbs-down - %button.btn.btn-primary.btn-sm{type: :button, name: 'mod-comments', data: { id: report.id, state: :hidden }} - %i.fa.fa-comments - %span{id: "mod-comment-count-#{report.id}"}= report.moderation_comments.all.count - %button.btn.btn-default.btn-sm{type: :button, name: "mod-delete-report", data: { id: report.id }} - %i.fa.fa-trash-o - .card-footer{id: "mod-comments-section-#{report.id}", style: 'display: none'} - %div{id: "mod-comments-#{report.id}"}= render 'moderation/discussion', report: report diff --git a/app/views/moderation/_userbox.html.haml b/app/views/moderation/_userbox.haml similarity index 57% rename from app/views/moderation/_userbox.html.haml rename to app/views/moderation/_userbox.haml index ad59b82e..0b604f6d 100644 --- a/app/views/moderation/_userbox.html.haml +++ b/app/views/moderation/_userbox.haml @@ -1,14 +1,16 @@ .card.h-100.userbox - %img.userbox__header{src: user.profile_header.url(:mobile)} + %img.userbox__header{ src: user.profile_header.url(:mobile) } .card-body - %img.userbox__avatar{src: user.profile_picture.url(:small)} - %a.profile__name{href: show_user_profile_path(user.screen_name)} + %img.userbox__avatar{ src: user.profile_picture.url(:small) } + %a.profile__name{ href: show_user_profile_path(user.screen_name) } - unless user.display_name.blank? .profile__display-name = user.display_name + .profile__screen-name + = user.screen_name .row .col-md-12.col-sm-12.col-xs-12 - - unless count.nil? + - if count.positive? %h4.entry-text.text-center#asked-count = count = 'Report'.pluralize(count)