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 { 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) { for (const pathPart of path) {
let newConfigPart = configPart[pathPart]; let newConfigPart = configPart[pathPart];
if (newConfigPart === undefined) { if (newConfigPart === undefined) {
console.warn("Lost the way for path ", path, " - creating entry")
if (typeof (pathPart) === "string") { if (typeof (pathPart) === "string") {
configPart[pathPart] = {}; configPart[pathPart] = {};
} else { } else {

View file

@ -34,12 +34,17 @@ export default class TagRenderingPreview extends UIElement {
let es = tagRenderingPanel.GetValue(); let es = tagRenderingPanel.GetValue();
let rendering: UIElement; let rendering: UIElement;
const self = this;
try { try {
rendering = rendering =
new VariableUiElement(es.map(tagRenderingConfig => { new VariableUiElement(es.map(tagRenderingConfig => {
const tr = FromJSON.TagRendering(tagRenderingConfig, "preview") try {
.construct({tags: this.previewTagValue}); const tr = FromJSON.TagRendering(tagRenderingConfig, "preview")
return tr.Render(); .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) self.IsSelected.setData(true)
}); });
this.value.addCallback((t) => { this.value.addCallback((t) => {
console.log("Setting actual value to", t);
const field = document.getElementById("txt-"+this.id); const field = document.getElementById("txt-"+this.id);
if (field === undefined || field === null) { if (field === undefined || field === null) {
return; return;

View file

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

View file

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