Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
Merge pull request #239 from paviliondev/character_counter_fix
COMPATIBILITY: Character counter is now a core component
Dieser Commit ist enthalten in:
Commit
d3e4b16610
4 geänderte Dateien mit 27 neuen und 24 gelöschten Zeilen
|
@ -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 = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
|
|
||||||
"wizard.x_characters",
|
|
||||||
{ count: parseInt(maxLength, 10) }
|
|
||||||
)}</div>`;
|
|
||||||
} else {
|
|
||||||
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
|
|
||||||
count: parseInt(bodyLength, 10),
|
|
||||||
})}</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Handlebars.SafeString(finalString);
|
|
||||||
});
|
|
25
assets/javascripts/discourse/helpers/wizard-char-counter.js.es6
Normale Datei
25
assets/javascripts/discourse/helpers/wizard-char-counter.js.es6
Normale Datei
|
@ -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 = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
|
||||||
|
"wizard.x_characters",
|
||||||
|
{ count: parseInt(maxLength, 10) }
|
||||||
|
)}</div>`;
|
||||||
|
} else {
|
||||||
|
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
|
||||||
|
count: parseInt(bodyLength, 10),
|
||||||
|
})}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Handlebars.SafeString(finalString);
|
||||||
|
}
|
||||||
|
);
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
{{#if field.char_counter}}
|
{{#if field.char_counter}}
|
||||||
{{#if textType}}
|
{{#if textType}}
|
||||||
{{char-counter field.value field.max_length}}
|
{{wizard-char-counter field.value field.max_length}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
# name: discourse-custom-wizard
|
# name: discourse-custom-wizard
|
||||||
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
|
# 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
|
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
|
||||||
# url: https://github.com/paviliondev/discourse-custom-wizard
|
# url: https://github.com/paviliondev/discourse-custom-wizard
|
||||||
# contact_emails: development@pavilion.tech
|
# contact_emails: development@pavilion.tech
|
||||||
|
|
Laden …
In neuem Issue referenzieren