From 6bcc24eabcef135cd97189858ccba87858415c40 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 30 Mar 2023 12:02:01 +0800 Subject: [PATCH 1/3] Namespace char-counter helper --- .../helpers/{char-counter.js.es6 => wizard-char-counter.js.es6} | 2 +- .../discourse/templates/components/custom-wizard-field.hbs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename assets/javascripts/discourse/helpers/{char-counter.js.es6 => wizard-char-counter.js.es6} (89%) diff --git a/assets/javascripts/discourse/helpers/char-counter.js.es6 b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 similarity index 89% rename from assets/javascripts/discourse/helpers/char-counter.js.es6 rename to assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 index a700a432..3cf4aee1 100644 --- a/assets/javascripts/discourse/helpers/char-counter.js.es6 +++ b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 @@ -2,7 +2,7 @@ import { registerUnbound } from "discourse-common/lib/helpers"; import I18n from "I18n"; import Handlebars from "handlebars"; -export default registerUnbound("char-counter", function (body, maxLength) { +export default registerUnbound("wizard-char-counter", function (body, maxLength) { let bodyLength = body ? body.length : 0; let finalString; diff --git a/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs b/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs index efda8629..a95f9fef 100644 --- a/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs +++ b/assets/javascripts/discourse/templates/components/custom-wizard-field.hbs @@ -20,7 +20,7 @@ {{#if field.char_counter}} {{#if textType}} - {{char-counter field.value field.max_length}} + {{wizard-char-counter field.value field.max_length}} {{/if}} {{/if}} From c4e2f2a4a88866bc60e2748e8a76d2f82213c0ca Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 30 Mar 2023 12:02:20 +0800 Subject: [PATCH 2/3] Update plugin.rb --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 1cf51e6a..758b5980 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-custom-wizard # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. -# version: 2.2.17 +# version: 2.2.18 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech From fa3e2d0c55124dc47b53a608e1d0fd16db26ef47 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 30 Mar 2023 12:09:00 +0800 Subject: [PATCH 3/3] Update wizard-char-counter.js.es6 --- .../helpers/wizard-char-counter.js.es6 | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 index 3cf4aee1..1e194314 100644 --- a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 +++ b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 @@ -2,21 +2,24 @@ import { registerUnbound } from "discourse-common/lib/helpers"; import I18n from "I18n"; import Handlebars from "handlebars"; -export default registerUnbound("wizard-char-counter", function (body, maxLength) { - let bodyLength = body ? body.length : 0; - let finalString; +export default registerUnbound( + "wizard-char-counter", + function (body, maxLength) { + let bodyLength = body ? body.length : 0; + let finalString; - if (maxLength) { - let isOverMax = bodyLength > maxLength ? "true" : "false"; - finalString = `
${bodyLength} / ${I18n.t( - "wizard.x_characters", - { count: parseInt(maxLength, 10) } - )}
`; - } else { - finalString = `
${I18n.t("wizard.x_characters", { - count: parseInt(bodyLength, 10), - })}
`; + if (maxLength) { + let isOverMax = bodyLength > maxLength ? "true" : "false"; + finalString = `
${bodyLength} / ${I18n.t( + "wizard.x_characters", + { count: parseInt(maxLength, 10) } + )}
`; + } else { + finalString = `
${I18n.t("wizard.x_characters", { + count: parseInt(bodyLength, 10), + })}
`; + } + + return new Handlebars.SafeString(finalString); } - - return new Handlebars.SafeString(finalString); -}); +);