Fix bug with multianswers triggering an error

This commit is contained in:
pietervdvn 2021-02-21 00:15:03 +01:00
parent 25be01b8ad
commit f4f7ae8f93
4 changed files with 9 additions and 22 deletions

View file

@ -86,12 +86,8 @@ export class UIEventSource<T> {
}
public ping(): void {
const old = this.data;
for (const callback of this._callbacks) {
callback(this.data);
if(this.data === undefined && old !== undefined){
throw "Something undefined the data!"
}
}
}

View file

@ -2,7 +2,7 @@ import { Utils } from "../Utils";
export default class Constants {
public static vNumber = "0.5.0-rc5";
public static vNumber = "0.5.0a";
// The user journey states thresholds when a new feature gets unlocked
public static userJourney = {

View file

@ -190,15 +190,20 @@ export default class TagRenderingQuestion extends UIElement {
freeformField?.GetValue()?.addCallbackAndRun(value => {
// The list of indices of the selected elements
const es = checkBoxes.GetValue();
const i = elements.length - 1;
// The actual index of the freeform-element
const index = es.data.indexOf(i);
if (value === undefined) {
// No data is set in the freeform text field; so we delete the checkmark if it is selected
if (index >= 0) {
es.data.splice(index, 1);
es.ping();
}
} else if (index < 0) {
// There is data defined in the checkmark, but the checkmark isn't checked, so we check it
// This is of course because the data changed
es.data.push(i);
es.ping();
}

View file

@ -1,7 +1,7 @@
// We HAVE to mark this while importing
import {Utils} from "../Utils";
Utils.runningFromConsole = true;
const sharp = require('sharp');
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
@ -55,7 +55,7 @@ function validate(layout: LayoutConfig) {
}
}
let message = `Translation completenes for theme ${layout.id}`
let message = `Translation completeness for theme ${layout.id}`
let isComplete = true;
for (const ln of layout.language) {
const amiss = missing[ln];
@ -121,25 +121,11 @@ async function createIcon(iconPath: string, size: number, layout: LayoutConfig)
}
try {
console.log("Could not create icon! ", name, newname)
/*
// We already read to file, in order to crash here if the file is not found
readFileSync(iconPath);
let img = await sharp(iconPath)
let resized = await img.resize(size)
await resized.toFile(newname)
/* svg2img(iconPath,
// @ts-ignore
{width: size, height: size, preserveAspectRatio: true})
.then((buffer) => {
console.log("Writing icon", newname)
writeFileSync(newname, buffer);
}).catch((error) => {
console.log("ERROR while writing" + iconPath, error)
});
//*/
} catch (e) {
console.error("Could not read icon", iconPath, "due to", e)
}