Fixed erronous clearing of value-fields in tagmappings, (hopefully) fixes #131

This commit is contained in:
Pieter Vander Vennet 2020-09-27 20:51:37 +02:00
parent 6509358f84
commit c53ccb7bae
6 changed files with 20 additions and 7 deletions

View file

@ -17,7 +17,16 @@ export default class Combine extends UIElement {
}
InnerRender(): string {
return this.uiElements.map(ui => ui.Render()).join("");
return this.uiElements.map(ui => {
if(ui === undefined || ui === null){
return "";
}
if(ui.Render === undefined){
console.error("Not a UI-element", ui);
return "";
}
return ui.Render();
}).join("");
}
}

View file

@ -48,7 +48,6 @@ export default class SingleSetting<T> {
for (const pathPart of path) {
let newConfigPart = configPart[pathPart];
if (newConfigPart === undefined) {
console.warn("Lost the way for path ", path, " - creating entry")
if (typeof (pathPart) === "string") {
configPart[pathPart] = {};
} else {

View file

@ -34,12 +34,17 @@ export default class TagRenderingPreview extends UIElement {
let es = tagRenderingPanel.GetValue();
let rendering: UIElement;
const self = this;
try {
rendering =
new VariableUiElement(es.map(tagRenderingConfig => {
const tr = FromJSON.TagRendering(tagRenderingConfig, "preview")
.construct({tags: this.previewTagValue});
return tr.Render();
try {
const tr = FromJSON.TagRendering(tagRenderingConfig, "preview")
.construct({tags: self.previewTagValue});
return tr.Render();
} catch (e) {
return new Combine(["Could not show this tagrendering:", e.message]).Render();
}
}
));

View file

@ -37,7 +37,6 @@ export class TextField extends InputElement<string> {
self.IsSelected.setData(true)
});
this.value.addCallback((t) => {
console.log("Setting actual value to", t);
const field = document.getElementById("txt-"+this.id);
if (field === undefined || field === null) {
return;

View file

@ -271,7 +271,7 @@ export default class ValidatedTextField {
country?: string
}): InputElement<T> {
let textField: InputElement<string>;
if (options.type) {
if (options?.type) {
textField = ValidatedTextField.InputForType(options.type, options);
} else {
textField = new TextField(options);

View file

@ -493,6 +493,7 @@ export class TagRendering extends UIElement implements TagDependantUIElement {
if (this.IsKnown()) {
const answer = this.RenderAnswer();
if (answer.IsEmpty()) {
return "";
}