From c1226522757cf2314915a97c5d14f35ac4c04219 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 10:36:23 +0100 Subject: [PATCH 1/3] 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") From c7cc0da04b4fdca51bcf5a2ebe71f4b06fd1dde8 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 10:57:05 +0100 Subject: [PATCH 2/3] Appease the dog overlords --- app/views/answerbox/_comments.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/answerbox/_comments.html.haml b/app/views/answerbox/_comments.html.haml index ac855d52..16312cc1 100644 --- a/app/views/answerbox/_comments.html.haml +++ b/app/views/answerbox/_comments.html.haml @@ -25,7 +25,8 @@ %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": 512 } } + .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" } } 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") From e18b9518aa97995bc8329125112463d5e9d2a9f2 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 22 Jan 2023 11:14:24 +0100 Subject: [PATCH 3/3] Properly align the hashes --- app/views/answerbox/_comments.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/answerbox/_comments.html.haml b/app/views/answerbox/_comments.html.haml index 16312cc1..ff77e2ee 100644 --- a/app/views/answerbox/_comments.html.haml +++ b/app/views/answerbox/_comments.html.haml @@ -25,8 +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: 512 } } + .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" } } 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")