From 251fe4c9fb5774055da03a36d04dc7f6a98d5de0 Mon Sep 17 00:00:00 2001 From: wninohira Date: Fri, 1 Jul 2022 10:56:53 -0400 Subject: [PATCH 1/6] Add Comment model and controller --- app/assets/stylesheets/comments.css | 4 ++++ app/controllers/comments_controller.rb | 2 ++ app/helpers/comments_helper.rb | 2 ++ app/models/comment.rb | 11 +++++++++++ db/migrate/20220630164320_create_comments.rb | 12 ++++++++++++ test/controllers/comments_controller_test.rb | 7 +++++++ test/fixtures/comments.yml | 7 +++++++ test/models/comment_test.rb | 7 +++++++ 8 files changed, 52 insertions(+) create mode 100644 app/assets/stylesheets/comments.css create mode 100644 app/controllers/comments_controller.rb create mode 100644 app/helpers/comments_helper.rb create mode 100644 app/models/comment.rb create mode 100644 db/migrate/20220630164320_create_comments.rb create mode 100644 test/controllers/comments_controller_test.rb create mode 100644 test/fixtures/comments.yml create mode 100644 test/models/comment_test.rb diff --git a/app/assets/stylesheets/comments.css b/app/assets/stylesheets/comments.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/app/assets/stylesheets/comments.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 00000000..76699551 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,2 @@ +class CommentsController < ApplicationController +end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 00000000..0ec9ca5f --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 00000000..c4f3f427 --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,11 @@ +class Comment < ApplicationRecord + validates_presence_of :report_id, + :commenter_id, + :body + + belongs_to :commenter, class_name: :User, foreign_key: :commenter_id + belongs_to :report + belongs_to :parent_comment, class_name: :Comment, foreign_key: :parent_comment_id, oprional: true + has_many :replies, class_name: :Comment, foreign_key: :parent_comment_id + +end diff --git a/db/migrate/20220630164320_create_comments.rb b/db/migrate/20220630164320_create_comments.rb new file mode 100644 index 00000000..043ce701 --- /dev/null +++ b/db/migrate/20220630164320_create_comments.rb @@ -0,0 +1,12 @@ +class CreateComments < ActiveRecord::Migration[6.0] + def change + create_table :comments do |t| + t.integer :report_id + t.integer :commenter_id + t.text :body + t.integer :parent_comment_id + + t.timestamps + end + end +end diff --git a/test/controllers/comments_controller_test.rb b/test/controllers/comments_controller_test.rb new file mode 100644 index 00000000..a812ddae --- /dev/null +++ b/test/controllers/comments_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml new file mode 100644 index 00000000..39882706 --- /dev/null +++ b/test/fixtures/comments.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + report_id: 1 + +two: + report_id: 1 diff --git a/test/models/comment_test.rb b/test/models/comment_test.rb new file mode 100644 index 00000000..b6d6131a --- /dev/null +++ b/test/models/comment_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CommentTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From a9a610803b2bda152b97cecf553a6b54747536f4 Mon Sep 17 00:00:00 2001 From: wninohira Date: Wed, 6 Jul 2022 17:47:21 -0400 Subject: [PATCH 2/6] Create comment actions(new and create) and add comments layout within report view --- app/assets/javascripts/report-comment.js | 9 +++++ app/assets/stylesheets/reports.css | 10 ++++- app/controllers/comments_controller.rb | 17 +++++++++ app/controllers/reports_controller.rb | 38 ++++++++++--------- app/models/comment.rb | 4 +- app/models/report.rb | 25 ++++++------ app/views/comments/create.js.erb | 6 +++ app/views/reports/_comment.html.erb | 8 ++++ app/views/reports/show.html.erb | 12 +++++- config/routes.rb | 20 +++++----- ...desired_outcome_to_recommended_response.rb | 5 --- db/schema.rb | 15 +++++++- 12 files changed, 118 insertions(+), 51 deletions(-) create mode 100644 app/assets/javascripts/report-comment.js create mode 100644 app/views/comments/create.js.erb create mode 100644 app/views/reports/_comment.html.erb delete mode 100644 db/migrate/20190904053235_change_desired_outcome_to_recommended_response.rb diff --git a/app/assets/javascripts/report-comment.js b/app/assets/javascripts/report-comment.js new file mode 100644 index 00000000..87195800 --- /dev/null +++ b/app/assets/javascripts/report-comment.js @@ -0,0 +1,9 @@ +/* + * When comment is submitted successfully + * it clears out the text field + */ +$(function() { + $('#new_comment').on('ajax:success', function(a, b,c ) { + $(this).find('#comment_body').val(''); + }); +}); diff --git a/app/assets/stylesheets/reports.css b/app/assets/stylesheets/reports.css index 182a1cf4..dcf6f4a9 100644 --- a/app/assets/stylesheets/reports.css +++ b/app/assets/stylesheets/reports.css @@ -54,6 +54,12 @@ font-size: 0.9em; } +#backstage-container .comment-row { + padding: 0.5em 1.25em 0.5em 1.25em; + font-size: 0.85em; + line-height: 1.75em; +} + #backstage-container .report-buttons { margin-top: 2em; } @@ -99,7 +105,7 @@ #backstage-container .report-buttons .button:focus { cursor: pointer; - background-color: var(--bright-blue-color); + background-color: var(--bright-blue-color); outline: none; } @@ -118,7 +124,7 @@ margin-left: 0em; margin-top: 2em; } - + #backstage-container .report-buttons a.stealth { margin-left: auto; margin-right: auto; diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 76699551..30d1a2f3 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,2 +1,19 @@ class CommentsController < ApplicationController + + def create + @comment = Comment.new(comment_params) + @comment.commenter = current_user + @comment.save + + respond_to do |format| + format.js + end + + end + + private + + def comment_params + params.require(:comment).permit(:body, :report_id) + end end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 396dcacb..14e89406 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,13 +1,13 @@ class ReportsController < ApplicationController - + layout "backstage", only: [ :index, :show ] - + before_action :authenticate_user!, only: [ :index, :show, :dismiss, :undismiss ] before_action :ensure_staff, only: [ :index, :show, :dismiss, :undismiss ] before_action :find_report, only: [ :show, :dismiss, :undismiss ] before_action :find_reported_twitch_user, only: [ :show ] around_action :display_timezone - + def index # f is used to filter reports by scope if params[:f].present? && Report::AVAILABLE_SCOPES.key?(params[:f].to_sym) @@ -19,7 +19,7 @@ def index @filter_category = "unresolved" end end - + def show # Create keybot advice message if @reported_twitch_user == nil @@ -29,30 +29,32 @@ def show else @message = "The reported Twitch user did not sign the pledge." end - + + @comment = Comment.new(report: @report) + @comments = @report.comments.includes(:commenter) # TODO: check if reporter has pledged (lookup email/Twitch name) and add info to keybot message # TODO: check if incident stream owner has pledged (Twitch name) and add info to keybot message end - + def new @report = Report.new end def create @report = Report.new(report_params) - + if @report.save # Email notification to staff StaffMailer.notify_staff_new_report(@report).deliver_now - + flash[:notice] = "You've successfully submitted the report. Thank you." redirect_to root_path - else + else flash.now[:alert] ||= "" @report.errors.full_messages.each do |message| flash.now[:alert] << message + ". " - end + end render(action: :new) end end @@ -65,14 +67,14 @@ def dismiss end redirect_to reports_path end - + def undismiss @report.dismissed = false @report.reviewer = nil if @report.save flash[:notice] = "You undismissed the report about #{@report.reported_twitch_name}. It can now be reviewed again." redirect_to report_path(@report) - else + else redirect_to reports_path end end @@ -83,11 +85,11 @@ def find_report rescue ActiveRecord::RecordNotFound redirect_to staff_index_path end - + def find_reported_twitch_user # Check if reported_twitch_name exists on Twitch response = HTTParty.get(URI.escape("#{ENV['TWITCH_API_BASE_URL']}/users?login=#{@report.reported_twitch_name}"), headers: {"Client-ID": ENV['TWITCH_CLIENT_ID'], "Authorization": "Bearer #{TwitchToken.first.valid_token!}"}) - + if response["data"].blank? @reported_twitch_user = nil else @@ -95,20 +97,20 @@ def find_reported_twitch_user end end - private + private def ensure_staff unless current_user.is_moderator? || current_user.is_admin? redirect_to root_url end end - + def display_timezone timezone = Time.find_zone( cookies[:browser_timezone] ) Time.use_zone(timezone) { yield } end - + def report_params params.require(:report).permit(:reporter_email, :reporter_twitch_name, :reported_twitch_name, :incident_stream, :incident_occurred, :incident_description, :recommended_response, :image) end - + end diff --git a/app/models/comment.rb b/app/models/comment.rb index c4f3f427..7e02768c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -5,7 +5,7 @@ class Comment < ApplicationRecord belongs_to :commenter, class_name: :User, foreign_key: :commenter_id belongs_to :report - belongs_to :parent_comment, class_name: :Comment, foreign_key: :parent_comment_id, oprional: true - has_many :replies, class_name: :Comment, foreign_key: :parent_comment_id + belongs_to :parent_comment, class_name: :Comment, foreign_key: :parent_comment_id, optional: true + has_many :replies, class_name: :Comment, foreign_key: :parent_comment_id end diff --git a/app/models/report.rb b/app/models/report.rb index a36a0acb..590f8420 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,5 +1,5 @@ class Report < ApplicationRecord - + AVAILABLE_SCOPES = { unresolved: "Unresolved", dismissed: "Dismissed", @@ -7,12 +7,12 @@ class Report < ApplicationRecord revoked: "Revoked", all: "All" }.freeze - + IMAGE_STYLES = { thumb: { resize: "120x120" }, preview: { resize: "240x240" } }.freeze - + validates_presence_of :reported_twitch_name, :incident_stream, :incident_description, @@ -24,22 +24,23 @@ class Report < ApplicationRecord validates :incident_description, length: { maximum: 1000 } - + validates :recommended_response, length: { maximum: 500 } validate :ensure_sane_review belongs_to :reviewer, class_name: :User, foreign_key: :reviewer_id, optional: true - + has_many :comments, class_name: :Comment, foreign_key: :report_id + image_accessor :image - + scope :dismissed, lambda { where("#{table_name}.dismissed IS TRUE") } scope :warned, lambda { where("#{table_name}.warned IS TRUE") } scope :revoked, lambda { where("#{table_name}.revoked IS TRUE") } scope :unresolved, lambda { where("#{table_name}.dismissed IS FALSE AND #{table_name}.warned IS FALSE AND #{table_name}.revoked IS FALSE") } - - + + def image_url(style = :thumb) if style == :original self.image.remote_url @@ -47,7 +48,7 @@ def image_url(style = :thumb) process_image(style).url end end - + protected def ensure_sane_review if (self.dismissed || self.warned || self.revoked) && !(self.dismissed ^ self.warned ^ self.revoked) @@ -62,10 +63,10 @@ def ensure_sane_review end end end - + private - def process_image(style) + def process_image(style) self.image.process(:auto_orient).thumb(Report::IMAGE_STYLES[style][:resize]) end - + end diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 00000000..5dbecc0b --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,6 @@ +/* + * When new comment is created + * it gets added to the view + */ + +$('#comments').append("<%= j(render 'reports/comment', comment: @comment) %>"); diff --git a/app/views/reports/_comment.html.erb b/app/views/reports/_comment.html.erb new file mode 100644 index 00000000..789a01e6 --- /dev/null +++ b/app/views/reports/_comment.html.erb @@ -0,0 +1,8 @@ +
+
+
+ <%= image_tag(user_image_src(current_user, :tiny), size: "28x28", class: "header-avatar") %>
+
<%= comment.commenter.first_name %>
+
<%= comment.body %>
+
+
diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb index b8e6e098..a698f2ee 100644 --- a/app/views/reports/show.html.erb +++ b/app/views/reports/show.html.erb @@ -13,13 +13,23 @@
Keybot says: <%= @message %> +
<%= render(partial: "comment", collection: @comments, as: :comment) %>
+ <%= form_with model: @comment, id: "new_comment" do |form| %> +
+ <%= form.text_field :body, size: "70x5" %> + <%= form.hidden_field :report_id, value: @report.id %> +
+ <%= form.submit "Send", class: 'button' %> +
+
+ <% end %>
<% if @report.dismissed %> <%= link_to("Undismiss", undismiss_report_path(@report), method: :post, class: 'dismiss-button button') %> <% elsif @report.warned %>
Warned
<% elsif @report.revoked %> -
Revoked
+
Revoked
<% else %> <% if @pledge %> <%= link_to("Revoke", new_report_revocation_path(@report, back: request.fullpath), class: 'revoke-button button') %> diff --git a/config/routes.rb b/config/routes.rb index 92887d6b..58a0af85 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,18 +1,18 @@ Rails.application.routes.draw do - + devise_for :users, controllers: { invitations: "users/invitations" }, path_names: { sign_in: "login", sign_out: "logout" } - + scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do - + authenticated :user do root to: "home#index", as: :authenticated_user_root end - + unauthenticated do root to: "home#index" end - + resources :pledges, only: [ :index, :create, :show ] get '/pledge', to: 'pledges#new', as: :new_pledge get '/take-the-pledge', to: 'pledges#new' @@ -22,8 +22,8 @@ resources :affiliates, only: [ :index, :new, :create, :edit, :update ] resources :resources, only: [ :index ] get '/research', to: 'resources#index', as: :research - get '/keystone-code', to: 'resources#keystone_code', as: :keystone_code - get '/inclusion-101', to: 'resources#inclusion_101', as: :inclusion_101 + get '/keystone-code', to: 'resources#keystone_code', as: :keystone_code + get '/inclusion-101', to: 'resources#inclusion_101', as: :inclusion_101 resources :stories, only: [ :index, :new, :create, :edit, :update ] get '/changemakers', to: 'stories#changemakers', as: :changemakers resources :reports, only: [ :index, :show, :new, :create ] do @@ -39,7 +39,7 @@ resources :staff, only: [ :index ] resources :users, only: [ :index, :show, :edit, :update ] post '/users/:id/remove_avatar', to: 'users#remove_avatar', as: :remove_avatar - + get '/about', to: 'about#index', as: :about get '/contact', to: 'about#contact', as: :contact get '/data-policy', to: 'about#data_policy', as: :data_policy @@ -48,6 +48,8 @@ get '/donate', to: 'donate#index', as: :donate get '/donate/success', to: 'donate#success', as: :donate_success + resources :comments, only: [ :new, :create] + end - + end diff --git a/db/migrate/20190904053235_change_desired_outcome_to_recommended_response.rb b/db/migrate/20190904053235_change_desired_outcome_to_recommended_response.rb deleted file mode 100644 index 7715639f..00000000 --- a/db/migrate/20190904053235_change_desired_outcome_to_recommended_response.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeDesiredOutcomeToRecommendedResponse < ActiveRecord::Migration[6.0] - def change - rename_column :reports, :desired_outcome, :recommended_response - end -end diff --git a/db/schema.rb b/db/schema.rb index baa309b8..04c5b34b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_02_23_190839) do +ActiveRecord::Schema.define(version: 2022_06_30_164320) do create_table "affiliates", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci", force: :cascade do |t| t.string "name" @@ -29,6 +29,15 @@ t.string "mixer" end + create_table "comments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci", force: :cascade do |t| + t.integer "report_id" + t.integer "commenter_id" + t.text "body" + t.integer "parent_comment_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "conduct_warnings", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci", force: :cascade do |t| t.integer "pledge_id" t.integer "report_id" @@ -55,6 +64,7 @@ t.datetime "twitch_authed_on" t.integer "referrer_id" t.integer "referrals_count", default: 0 + t.integer "reports_count" end create_table "reports", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci", force: :cascade do |t| @@ -72,6 +82,7 @@ t.boolean "dismissed", default: false t.boolean "warned", default: false t.boolean "revoked", default: false + t.integer "twitch_id" t.index ["reviewer_id"], name: "index_reports_on_reviewer_id" end @@ -96,7 +107,7 @@ t.datetime "published_on" end - create_table "twitch_tokens", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t| + create_table "twitch_tokens", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci", force: :cascade do |t| t.string "access_token" t.integer "expires_in" t.datetime "created_at", precision: 6, null: false From cc56eb5f4b93253e1ca73f60932904d2c70370f2 Mon Sep 17 00:00:00 2001 From: wninohira Date: Tue, 12 Jul 2022 19:36:45 -0400 Subject: [PATCH 3/6] Clean up the layout and style for report review page. Adds comment icon next to report with comment in report list view. --- app/assets/stylesheets/backstage.css | 23 ++++++++---- app/assets/stylesheets/reports.css | 48 ++++++++++++++++++++++++-- app/controllers/comments_controller.rb | 9 ++--- app/views/comments/create.js.erb | 2 +- app/views/reports/_comment.html.erb | 8 ++--- app/views/reports/_row.html.erb | 11 ++++-- app/views/reports/show.html.erb | 23 ++++++------ 7 files changed, 94 insertions(+), 30 deletions(-) diff --git a/app/assets/stylesheets/backstage.css b/app/assets/stylesheets/backstage.css index 4a97b3f2..35552337 100644 --- a/app/assets/stylesheets/backstage.css +++ b/app/assets/stylesheets/backstage.css @@ -17,7 +17,7 @@ border: solid 5px var(--black-color); -moz-box-sizing: border-box; -webkit-box-sizing: border-box; - box-sizing: border-box; + box-sizing: border-box; } #backstage-container .panel-title { @@ -74,7 +74,7 @@ #backstage-container .panel-menu a:focus { cursor: pointer; - background-color: var(--bright-blue-color); + background-color: var(--bright-blue-color); outline: none; } @@ -92,7 +92,7 @@ #backstage-container .panel-filters a.selected { font-weight: 700; - color: var(--light-black-color); + color: var(--light-black-color); } #backstage-container .panel-filters a:hover { @@ -119,12 +119,21 @@ #backstage-container .record-row:hover { cursor: pointer; - background: var(--orange-overlay); + background: var(--orange-overlay); } #backstage-container .record-row:active { cursor: pointer; - background: var(--blue-overlay); + background: var(--blue-overlay); +} + +#backstage-container .record-row .icons-space { + width: 4.5em; +} + +#backstage-container .record-row .icons-space .icon { + font-family: var(--icon-font); + margin-right: 0.3em; } #backstage-container .record-row .row-title { @@ -160,12 +169,12 @@ width: auto; padding: 2em 2em 2em 2em; } - + #backstage-container .control-panel { min-width: 16em; padding: 2em 2em 2em 2em; } - + #backstage-container .panel-descriptor { text-align: left; } diff --git a/app/assets/stylesheets/reports.css b/app/assets/stylesheets/reports.css index dcf6f4a9..763cf16b 100644 --- a/app/assets/stylesheets/reports.css +++ b/app/assets/stylesheets/reports.css @@ -55,11 +55,55 @@ } #backstage-container .comment-row { - padding: 0.5em 1.25em 0.5em 1.25em; - font-size: 0.85em; + padding: 0.5em 1.25em 0.5em 0em; + font-size: 0.9em; line-height: 1.75em; } +#backstage-container .comment-row img.comment-avatar{ + min-width: 28px; + min-height: 28px; + border-radius: 14px; + -webkit-border-radius: 14px; + -moz-border-radius: 14px; +} + +#backstage-container .comment-row .comment-avatar-container { + margin-right: 0.3em; +} + +#backstage-container .comment-row .row-name { + margin-right: 1em; + font-weight: 500; +} + +#backstage-container .comment-field #comment_body{ + width: 80%; + height: 3em; +} + +#backstage-container .comment-field .send-button, +#backstage-container .comment-field .send-button:hover { + font-family: var(--solid-icon-font); + font-size: 1.8em; + border: none; + color: var(--bright-green-color); + background-color: inherit; + padding: 0.2em; + border-radius: 20%; + margin-left: 0.3em; +} + +#backstage-container .comment-field .send-button:hover { + cursor: pointer; + background-color: var(--dark-white-color); +} + +#backstage-container .button.send-button { + font-family: var(--solid-icon-font); + color: pink; +} + #backstage-container .report-buttons { margin-top: 2em; } diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 30d1a2f3..c724c51a 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -3,12 +3,13 @@ class CommentsController < ApplicationController def create @comment = Comment.new(comment_params) @comment.commenter = current_user - @comment.save - respond_to do |format| - format.js + if @comment.save + format.js + else + #TODO if not saved give alert? + end end - end private diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 5dbecc0b..11094d37 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -3,4 +3,4 @@ * it gets added to the view */ -$('#comments').append("<%= j(render 'reports/comment', comment: @comment) %>"); +$('#comment-view').append("<%= j(render 'reports/comment', comment: @comment) %>"); diff --git a/app/views/reports/_comment.html.erb b/app/views/reports/_comment.html.erb index 789a01e6..af7ee333 100644 --- a/app/views/reports/_comment.html.erb +++ b/app/views/reports/_comment.html.erb @@ -1,8 +1,8 @@
-
-
- <%= image_tag(user_image_src(current_user, :tiny), size: "28x28", class: "header-avatar") %>
-
<%= comment.commenter.first_name %>
+
+
+ <%= image_tag(user_image_src(current_user, :tiny), size: "28x28", class: "comment-avatar flexbox center") %>
+
<%= comment.commenter.first_name %>
<%= comment.body %>
diff --git a/app/views/reports/_row.html.erb b/app/views/reports/_row.html.erb index 7e1935f7..6a8a41be 100644 --- a/app/views/reports/_row.html.erb +++ b/app/views/reports/_row.html.erb @@ -1,6 +1,13 @@
flexbox vertical stretch" data-url="<%= report_path(report, back: request.fullpath) %>">
-
<%= report.reported_twitch_name %>
+
+
+ <% if report.comments.present? %> + + <% end %> +
+
<%= report.reported_twitch_name %>
+
<%= l(report.created_at, format: "%b. %-d, %Y · %-l:%M%P ") %>
-
\ No newline at end of file +
diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb index a698f2ee..a8122d63 100644 --- a/app/views/reports/show.html.erb +++ b/app/views/reports/show.html.erb @@ -11,18 +11,21 @@ <%= render(partial: "shared/report_body") %>

- Keybot says: <%= @message %> -
-
<%= render(partial: "comment", collection: @comments, as: :comment) %>
- <%= form_with model: @comment, id: "new_comment" do |form| %> -
- <%= form.text_field :body, size: "70x5" %> - <%= form.hidden_field :report_id, value: @report.id %> -
- <%= form.submit "Send", class: 'button' %> +
+
Comments by Mods
+
+
<%= render(partial: "comment", collection: @comments, as: :comment) %>
+ <%= form_with model: @comment, id: "new_comment", html: { autocomplete: "off" } do |form| %> +
+ <%= form.text_area :body, placeholder: "Leave comments for other moderators" %> + <%= form.hidden_field :report_id, value: @report.id %> + <%= form.submit class: "send-button", data: { disable_with: false }, value: "".html_safe %> +
+ <% end %> +
+
Keybot says: <%= @message %>
- <% end %>
<% if @report.dismissed %> <%= link_to("Undismiss", undismiss_report_path(@report), method: :post, class: 'dismiss-button button') %> From a5852d8799ff7f12bb7883d72f6ec93b5ed45c7c Mon Sep 17 00:00:00 2001 From: wninohira Date: Wed, 13 Jul 2022 18:29:43 -0400 Subject: [PATCH 4/6] Fixes avatar to show the right image --- app/views/reports/_comment.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/reports/_comment.html.erb b/app/views/reports/_comment.html.erb index af7ee333..8280ee33 100644 --- a/app/views/reports/_comment.html.erb +++ b/app/views/reports/_comment.html.erb @@ -1,7 +1,7 @@
- <%= image_tag(user_image_src(current_user, :tiny), size: "28x28", class: "comment-avatar flexbox center") %>
+ <%= image_tag(user_image_src(comment.commenter, :tiny), size: "28x28", class: "comment-avatar flexbox center") %>
<%= comment.commenter.first_name %>
<%= comment.body %>
From 6809cdda65cefe11f16baad64f5d32a8ee8af045 Mon Sep 17 00:00:00 2001 From: wninohira Date: Wed, 20 Jul 2022 17:35:12 -0400 Subject: [PATCH 5/6] Cleaned up css for the comment on reports --- app/assets/stylesheets/reports.css | 18 +++++++++++------- app/views/reports/_comment.html.erb | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/reports.css b/app/assets/stylesheets/reports.css index 763cf16b..e505823a 100644 --- a/app/assets/stylesheets/reports.css +++ b/app/assets/stylesheets/reports.css @@ -55,21 +55,21 @@ } #backstage-container .comment-row { - padding: 0.5em 1.25em 0.5em 0em; + padding: 0.3em 1.25em 0.3em 0em; font-size: 0.9em; line-height: 1.75em; } #backstage-container .comment-row img.comment-avatar{ - min-width: 28px; - min-height: 28px; - border-radius: 14px; - -webkit-border-radius: 14px; - -moz-border-radius: 14px; + min-width: 24px; + min-height: 24px; + border-radius: 12px; + -webkit-border-radius: 12px; + -moz-border-radius: 12px; } #backstage-container .comment-row .comment-avatar-container { - margin-right: 0.3em; + margin-right: 0.5em; } #backstage-container .comment-row .row-name { @@ -77,6 +77,10 @@ font-weight: 500; } +#backstage-container .comment-field { + margin-top: 0.5em; +} + #backstage-container .comment-field #comment_body{ width: 80%; height: 3em; diff --git a/app/views/reports/_comment.html.erb b/app/views/reports/_comment.html.erb index af7ee333..68b8cf87 100644 --- a/app/views/reports/_comment.html.erb +++ b/app/views/reports/_comment.html.erb @@ -1,7 +1,7 @@
- <%= image_tag(user_image_src(current_user, :tiny), size: "28x28", class: "comment-avatar flexbox center") %>
+ <%= image_tag(user_image_src(current_user, :tiny), size: "24x24", class: "comment-avatar flexbox center") %>
<%= comment.commenter.first_name %>
<%= comment.body %>
From 3a3a61bc5731931cb8db18f692150ec4c1741e40 Mon Sep 17 00:00:00 2001 From: wninohira Date: Thu, 21 Jul 2022 13:18:01 -0400 Subject: [PATCH 6/6] Adds date and time display to comment --- app/assets/stylesheets/reports.css | 11 +++++++++++ app/views/reports/_comment.html.erb | 13 +++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/reports.css b/app/assets/stylesheets/reports.css index e505823a..8d080981 100644 --- a/app/assets/stylesheets/reports.css +++ b/app/assets/stylesheets/reports.css @@ -70,6 +70,7 @@ #backstage-container .comment-row .comment-avatar-container { margin-right: 0.5em; + margin-top: 0.4em; } #backstage-container .comment-row .row-name { @@ -77,6 +78,16 @@ font-weight: 500; } +#backstage-container .comment-row .row-date { + margin-right: 1em; + font-size: 0.8em; + color: var(--gray-color); +} + +#backstage-container .comment-row .row-detail { + line-height: 1.5em; +} + #backstage-container .comment-field { margin-top: 0.5em; } diff --git a/app/views/reports/_comment.html.erb b/app/views/reports/_comment.html.erb index 68b8cf87..288fe531 100644 --- a/app/views/reports/_comment.html.erb +++ b/app/views/reports/_comment.html.erb @@ -1,8 +1,13 @@
-
+
- <%= image_tag(user_image_src(current_user, :tiny), size: "24x24", class: "comment-avatar flexbox center") %>
-
<%= comment.commenter.first_name %>
-
<%= comment.body %>
+ <%= image_tag(user_image_src(comment.commenter, :tiny), size: "24x24", class: "comment-avatar flexbox center") %>
+
+
+
<%= comment.commenter.first_name %>
+
<%= l(comment.created_at, format: "%b. %-d, %Y · %-l:%M%P ") %>
+
+
<%= comment.body %>
+