From f27ca60d24d698243787d99074ffcd5b382312d0 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Tue, 19 Jan 2021 12:17:07 +0530 Subject: [PATCH] updated char counter logic --- .../javascripts/wizard/helpers/char-counter.js.es6 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/javascripts/wizard/helpers/char-counter.js.es6 b/assets/javascripts/wizard/helpers/char-counter.js.es6 index b488d409..4cc12463 100644 --- a/assets/javascripts/wizard/helpers/char-counter.js.es6 +++ b/assets/javascripts/wizard/helpers/char-counter.js.es6 @@ -1,9 +1,16 @@ import { registerUnbound } from "discourse-common/lib/helpers"; import I18n from "I18n"; -export default registerUnbound("char-counter", function(body) { +export default registerUnbound("char-counter", function(body, maxLength) { let bodyLength = body ? body.length : 0; - let characterString = bodyLength == 1 ? 'wizard.character' : 'wizard.characters'; - let finalString = `
${bodyLength} ${ I18n.t(characterString)}
`; + let length = maxLength || bodyLength; + let characterString = length == 1 ? 'wizard.character' : 'wizard.characters'; + let finalString; + + if(maxLength) { + finalString = `
${bodyLength} / ${maxLength} ${ I18n.t(characterString)}
`; + } else { + finalString = `
${bodyLength} ${ I18n.t(characterString)}
`; + } return new Handlebars.SafeString(finalString); });