Better validated text fields with translations and human-friendly texts: first draft

This commit is contained in:
Pieter Vander Vennet 2022-02-11 04:28:11 +01:00
parent 695a0867c7
commit 9ab4fbd6f5
7 changed files with 581 additions and 528 deletions

View file

@ -17,6 +17,8 @@ import ReplaceGeometrySpec from "./ReplaceGeometry.spec";
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
import T from "./TestHelper";
import CreateNoteImportLayerSpec from "./CreateNoteImportLayer.spec";
import ValidatedTextFieldTranslations from "./ValidatedTextFieldTranslations.spec";
import ValidatedTextFieldTranslationsSpec from "./ValidatedTextFieldTranslations.spec";
async function main() {
@ -38,7 +40,8 @@ async function main() {
new ActorsSpec(),
new ReplaceGeometrySpec(),
new LegacyThemeLoaderSpec(),
new CreateNoteImportLayerSpec()
new CreateNoteImportLayerSpec(),
new ValidatedTextFieldTranslationsSpec()
]
Utils.externalDownloadFunction = async (url) => {

View file

@ -0,0 +1,27 @@
import T from "./TestHelper";
import ValidatedTextField from "../UI/Input/ValidatedTextField";
import Translations from "../UI/i18n/Translations";
export default class ValidatedTextFieldTranslationsSpec extends T {
constructor() {
super([
["Test all", () => {
const ts = Translations.t.validation;
console.log("Hello world!")
const allErrors = Array.from(ValidatedTextField.AllTypes.keys()).map(key => {
const errors = []
const t = ts[key]
if (t === undefined) {
errors.push("No tranlations at all for " + key)
}
return errors;
})
const errs = [].concat(...allErrors)
if (errs.length > 0) {
errs.forEach(e => console.log(e))
// throw errs.join("\n")
}
}]
]);
}
}