From df3e5b6494c42089a361bf855a2064423f88bfcc Mon Sep 17 00:00:00 2001 From: merefield Date: Thu, 16 Nov 2023 16:32:39 +0000 Subject: [PATCH] COMPATIBILITY: resolve register unbound deprecation --- .../discourse/helpers/wizard-char-counter.js | 21 ++++++++++++++++ .../helpers/wizard-char-counter.js.es6 | 25 ------------------- 2 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 assets/javascripts/discourse/helpers/wizard-char-counter.js delete mode 100644 assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 diff --git a/assets/javascripts/discourse/helpers/wizard-char-counter.js b/assets/javascripts/discourse/helpers/wizard-char-counter.js new file mode 100644 index 00000000..459792d8 --- /dev/null +++ b/assets/javascripts/discourse/helpers/wizard-char-counter.js @@ -0,0 +1,21 @@ +import I18n from "I18n"; +import Handlebars from "handlebars"; + +export default function wizardCharCounter(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), + })}
`; + } + + return new Handlebars.SafeString(finalString); +}; diff --git a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 deleted file mode 100644 index 1e194314..00000000 --- a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 +++ /dev/null @@ -1,25 +0,0 @@ -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; - - 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); - } -);