Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-26 11:00:28 +01:00
FEATURE: text length counter for text type fields
Dieser Commit ist enthalten in:
Ursprung
7389afe239
Commit
10f80709c2
4 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen
9
assets/javascripts/wizard/helpers/char-counter.js.es6
Normale Datei
9
assets/javascripts/wizard/helpers/char-counter.js.es6
Normale Datei
|
@ -0,0 +1,9 @@
|
||||||
|
import { registerUnbound } from "discourse-common/lib/helpers";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
export default registerUnbound("char-counter", function(body) {
|
||||||
|
let bodyLength = body ? body.length : 0;
|
||||||
|
let characterString = bodyLength == 1 ? 'wizard.character' : 'wizard.characters';
|
||||||
|
let finalString = `<div class="body-length">${bodyLength} ${ I18n.t(characterString)}</div>`;
|
||||||
|
return new Handlebars.SafeString(finalString);
|
||||||
|
});
|
|
@ -16,6 +16,10 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if textType}}
|
||||||
|
{{char-counter field.value}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if field.errorDescription}}
|
{{#if field.errorDescription}}
|
||||||
<div class='field-error-description'>{{{field.errorDescription}}}</div>
|
<div class='field-error-description'>{{{field.errorDescription}}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -80,3 +80,7 @@ textarea {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.body-length {
|
||||||
|
text-align: right;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
|
@ -469,6 +469,8 @@ en:
|
||||||
requires_login: "You need to be logged in to access this wizard."
|
requires_login: "You need to be logged in to access this wizard."
|
||||||
reset: "Reset this wizard."
|
reset: "Reset this wizard."
|
||||||
step_not_permitted: "You're not permitted to view this step."
|
step_not_permitted: "You're not permitted to view this step."
|
||||||
|
characters: "Characters"
|
||||||
|
character: "Character"
|
||||||
|
|
||||||
wizard_composer:
|
wizard_composer:
|
||||||
show_preview: "Preview Post"
|
show_preview: "Preview Post"
|
||||||
|
|
Laden …
In neuem Issue referenzieren