Merge pull request #983 from Retrospring/feature/long-comments

Increase allowed comment length to 512 characters
This commit is contained in:
Karina Kwiatek 2023-01-22 12:14:24 +01:00 committed by GitHub
commit 1ea8e64a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -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<HTMLElement>(`[data-action=ab-submarine][data-a-id="${id}"]`);
sub.dataset.torpedo = "no"

View File

@ -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

View File

@ -25,7 +25,10 @@
%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")