diff --git a/assets/javascripts/discourse/helpers/char-counter.js.es6 b/assets/javascripts/discourse/helpers/char-counter.js.es6 deleted file mode 100644 index a700a432..00000000 --- a/assets/javascripts/discourse/helpers/char-counter.js.es6 +++ /dev/null @@ -1,22 +0,0 @@ -import { registerUnbound } from "discourse-common/lib/helpers"; -import I18n from "I18n"; -import Handlebars from "handlebars"; - -export default registerUnbound("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); -}); diff --git a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 new file mode 100644 index 00000000..1e194314 --- /dev/null +++ b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 @@ -0,0 +1,25 @@ +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); + } +); 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}} 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