From c1226522757cf2314915a97c5d14f35ac4c04219 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 10:36:23 +0100 Subject: [PATCH] Increase allowed comment length to 512 characters --- app/javascript/retrospring/features/answerbox/comment/new.ts | 4 ++-- app/models/comment.rb | 2 +- app/views/answerbox/_comments.html.haml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/retrospring/features/answerbox/comment/new.ts b/app/javascript/retrospring/features/answerbox/comment/new.ts index adec5a76..7bbb8043 100644 --- a/app/javascript/retrospring/features/answerbox/comment/new.ts +++ b/app/javascript/retrospring/features/answerbox/comment/new.ts @@ -19,7 +19,7 @@ export function commentCreateHandler(event: KeyboardEvent): boolean { if (event.which === 13) { event.preventDefault(); - if (input.value.length > 160) { + if (input.value.length > 512) { group.classList.add('has-error'); return true; } @@ -43,7 +43,7 @@ export function commentCreateHandler(event: KeyboardEvent): boolean { commentCount.innerHTML = data.count; } input.value = ''; - counter.innerHTML = String(160); + counter.innerHTML = String(512); const sub = document.querySelector(`[data-action=ab-submarine][data-a-id="${id}"]`); sub.dataset.torpedo = "no" diff --git a/app/models/comment.rb b/app/models/comment.rb index 127524ef..7e982170 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -5,7 +5,7 @@ class Comment < ApplicationRecord validates :answer_id, presence: true has_many :smiles, class_name: "Appendable::Reaction", foreign_key: :parent_id, dependent: :destroy - validates :content, length: { maximum: 160 } + validates :content, length: { maximum: 512 } # rubocop:disable Rails/SkipsModelValidations after_create do diff --git a/app/views/answerbox/_comments.html.haml b/app/views/answerbox/_comments.html.haml index 9b906dfd..ac855d52 100644 --- a/app/views/answerbox/_comments.html.haml +++ b/app/views/answerbox/_comments.html.haml @@ -25,7 +25,7 @@ %span.caret = render "actions/comment", comment: comment, answer: a - if user_signed_in? - .form-group.has-feedback.comment__input-group.input-group{ name: "ab-comment-new-group", data: { a_id: a.id, controller: "character-count", "character-count-max-value": 160 } } + .form-group.has-feedback.comment__input-group.input-group{ name: "ab-comment-new-group", data: { a_id: a.id, controller: "character-count", "character-count-max-value": 512 } } %input.form-control.comment__input{ type: :text, placeholder: t(".placeholder"), name: "ab-comment-new", data: { a_id: a.id, "character-count-target": "input" } } - %span.text-muted.form-control-feedback.comment__character-count{ id: "ab-comment-charcount-#{a.id}", data: { "character-count-target": "counter" } } 160 + %span.text-muted.form-control-feedback.comment__character-count{ id: "ab-comment-charcount-#{a.id}", data: { "character-count-target": "counter" } } 512 %button.btn.btn-primary.d-none{ type: :button, name: "ab-comment-new-submit", data: { a_id: a.id, "character-count-target": "action" } }= t(".action")