Fix 'addExtraTags' in mappings

This commit is contained in:
Pieter Vander Vennet 2021-10-26 22:53:27 +02:00
parent bd3395af22
commit 78dbe0baa2
5 changed files with 2219 additions and 2339 deletions

View file

@ -49,7 +49,7 @@ export default class TagRenderingQuestion extends Combine {
const applicableMappingsSrc =
UIEventSource.ListStabilized(tags.map(tags => {
const applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter }[] = []
const applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter, addExtraTags: Tag[] }[] = []
for (const mapping of configuration.mappings ?? []) {
if (mapping.hideInAnswer === true) {
continue
@ -110,7 +110,7 @@ export default class TagRenderingQuestion extends Combine {
options.saveButtonConstr(inputElement.GetValue()),
new Toggle(Translations.t.general.testing.SetClass("alert"), undefined, State.state.featureSwitchIsTesting)
])
let bottomTags: BaseUIElement;
if (options.bottomText !== undefined) {
bottomTags = options.bottomText(inputElement.GetValue())
@ -147,7 +147,7 @@ export default class TagRenderingQuestion extends Combine {
private static GenerateInputElement(configuration: TagRenderingConfig,
applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter }[],
applicableMappings: { if: TagsFilter, then: any, ifnot?: TagsFilter, addExtraTags: Tag[] }[],
applicableUnit: Unit,
tagsSource: UIEventSource<any>)
: InputElement<TagsFilter> {
@ -341,12 +341,16 @@ export default class TagRenderingQuestion extends Combine {
mapping: {
if: TagsFilter,
then: Translation,
addExtraTags: Tag[]
}, ifNot?: TagsFilter[]): InputElement<TagsFilter> {
let tagging: TagsFilter = mapping.if;
if (ifNot !== undefined) {
tagging = new And([mapping.if, ...ifNot])
}
if (mapping.addExtraTags) {
tagging = new And([tagging, ...mapping.addExtraTags])
}
return new FixedInputElement(
new SubstitutedTranslation(mapping.then, tagsSource),