From 15f1a9362c624d3fec9680efa3e38edf912cbaf1 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 5 Jul 2021 00:45:41 +0200 Subject: [PATCH] Fix: ifnot-value would show up together with the 'if'-value --- Models/Constants.ts | 2 +- UI/Popup/TagRenderingQuestion.ts | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Models/Constants.ts b/Models/Constants.ts index 663dd007fc..ab65926b17 100644 --- a/Models/Constants.ts +++ b/Models/Constants.ts @@ -2,7 +2,7 @@ import { Utils } from "../Utils"; export default class Constants { - public static vNumber = "0.8.3-rc1"; + public static vNumber = "0.8.3-rc2"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/UI/Popup/TagRenderingQuestion.ts b/UI/Popup/TagRenderingQuestion.ts index 1da92105b9..52b2962d81 100644 --- a/UI/Popup/TagRenderingQuestion.ts +++ b/UI/Popup/TagRenderingQuestion.ts @@ -53,7 +53,6 @@ export default class TagRenderingQuestion extends Combine { const inputElement: InputElement = TagRenderingQuestion.GenerateInputElement(configuration, applicableUnit, tags) const save = () => { const selection = inputElement.GetValue().data; - console.log("Save button clicked, the tags are is", selection) if (selection) { (State.state?.changes ?? new Changes()) .addTag(tags.data.id, selection, tags); @@ -119,18 +118,27 @@ export default class TagRenderingQuestion extends Combine { }) - let allIfNots: TagsFilter[] = Utils.NoNull(configuration.mappings?.map(m => m.ifnot) ?? []); + function allIfNotsExcept(excludeIndex: number) : TagsFilter[]{ + if(configuration.mappings === undefined){ + return [] + } + if(configuration.multiAnswer){ + // The multianswer will do the ifnot configuration themself + return [] + } + return Utils.NoNull(configuration.mappings?.map((m,i) => excludeIndex === i ? undefined: m.ifnot)) + } const ff = TagRenderingQuestion.GenerateFreeform(configuration, applicableUnit, tagsSource.data); const hasImages = mappings.filter(mapping => mapping.then.ExtractImages().length > 0).length > 0 if (mappings.length < 8 || configuration.multiAnswer || hasImages) { - inputEls = (mappings ?? []).map(mapping => TagRenderingQuestion.GenerateMappingElement(tagsSource, mapping, allIfNots)); + inputEls = (mappings ?? []).map((mapping,i) => TagRenderingQuestion.GenerateMappingElement(tagsSource, mapping, allIfNotsExcept(i))); inputEls = Utils.NoNull(inputEls); } else { const dropdown: InputElement = new DropDown("", - mappings.map(mapping => { + mappings.map((mapping, i) => { return { - value: new And([mapping.if, ...allIfNots]), + value: new And([mapping.if, ...allIfNotsExcept(i)]), shown: Translations.WT(mapping.then).Clone() } })