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 { public ping(): void {
const old = this.data;
for (const callback of this._callbacks) { for (const callback of this._callbacks) {
callback(this.data); 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 { 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 // The user journey states thresholds when a new feature gets unlocked
public static userJourney = { public static userJourney = {

View file

@ -91,7 +91,7 @@ export default class TagRenderingQuestion extends UIElement {
).SetClass("block") ).SetClass("block")
} }
private GenerateInputElement(): InputElement<TagsFilter> { private GenerateInputElement(): InputElement<TagsFilter> {
const ff = this.GenerateFreeform(); const ff = this.GenerateFreeform();
const self = this; const self = this;
let mappings = let mappings =
@ -190,15 +190,20 @@ export default class TagRenderingQuestion extends UIElement {
freeformField?.GetValue()?.addCallbackAndRun(value => { freeformField?.GetValue()?.addCallbackAndRun(value => {
// The list of indices of the selected elements
const es = checkBoxes.GetValue(); const es = checkBoxes.GetValue();
const i = elements.length - 1; const i = elements.length - 1;
// The actual index of the freeform-element
const index = es.data.indexOf(i); const index = es.data.indexOf(i);
if (value === undefined) { if (value === undefined) {
// No data is set in the freeform text field; so we delete the checkmark if it is selected
if (index >= 0) { if (index >= 0) {
es.data.splice(index, 1); es.data.splice(index, 1);
es.ping(); es.ping();
} }
} else if (index < 0) { } 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.data.push(i);
es.ping(); es.ping();
} }

View file

@ -1,7 +1,7 @@
// We HAVE to mark this while importing // We HAVE to mark this while importing
import {Utils} from "../Utils"; import {Utils} from "../Utils";
Utils.runningFromConsole = true; Utils.runningFromConsole = true;
const sharp = require('sharp');
import LayoutConfig from "../Customizations/JSON/LayoutConfig"; import LayoutConfig from "../Customizations/JSON/LayoutConfig";
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"; 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; let isComplete = true;
for (const ln of layout.language) { for (const ln of layout.language) {
const amiss = missing[ln]; const amiss = missing[ln];
@ -121,25 +121,11 @@ async function createIcon(iconPath: string, size: number, layout: LayoutConfig)
} }
try { 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 // We already read to file, in order to crash here if the file is not found
readFileSync(iconPath); readFileSync(iconPath);
let img = await sharp(iconPath) let img = await sharp(iconPath)
let resized = await img.resize(size) let resized = await img.resize(size)
await resized.toFile(newname) 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) { } catch (e) {
console.error("Could not read icon", iconPath, "due to", e) console.error("Could not read icon", iconPath, "due to", e)
} }