diff --git a/UI/Popup/TagRendering.ts b/UI/Popup/TagRendering.ts index 5b1361b1ac..81595769e0 100644 --- a/UI/Popup/TagRendering.ts +++ b/UI/Popup/TagRendering.ts @@ -23,7 +23,7 @@ export class TagRendering extends UIElement implements TagDependantUIElement { private readonly _question: string | Translation; - private readonly _mapping: { k: TagsFilter, txt: string | Translation, priority?: number }[]; + private readonly _mapping: { k: TagsFilter, txt: string | Translation }[]; private readonly currentTags: UIEventSource; @@ -68,12 +68,17 @@ export class TagRendering extends UIElement implements TagDependantUIElement { }, tagsPreprocessor?: ((tags: any) => any), multiAnswer?: boolean, - mappings?: { k: TagsFilter, txt: string | Translation, priority?: number, substitute?: boolean, hideInAnswer?: boolean }[] + mappings?: { k: TagsFilter, txt: string | Translation, substitute?: boolean, hideInAnswer?: boolean }[] }) { super(tags); if (tags === undefined) { throw "No tags given for a tagrendering..." } + if (options.question !== undefined) { + if ((options.mappings?.length ?? 0) === 0 && options.freeform.key === undefined) { + throw "Error: question without mappings or key" + } + } this.ListenTo(Locale.language); this.ListenTo(this._editMode); this.ListenTo(this._questionSkipped); @@ -83,7 +88,7 @@ export class TagRendering extends UIElement implements TagDependantUIElement { this.currentTags = tags.map(tags => { - if (options.tagsPreprocessor === undefined) { + if (options.tagsPreprocessor === undefined) { return tags; } // we clone the tags... @@ -111,7 +116,6 @@ export class TagRendering extends UIElement implements TagDependantUIElement { let choiceSubbed = { k: choice.k?.substituteValues(this.currentTags.data), txt: choice.txt, - priority: choice.priority } @@ -202,7 +206,7 @@ export class TagRendering extends UIElement implements TagDependantUIElement { extraTags?: TagsFilter, }, multiAnswer?: boolean, - mappings?: { k: TagsFilter, txt: string | Translation, priority?: number, substitute?: boolean, hideInAnswer?: boolean }[] + mappings?: { k: TagsFilter, txt: string | Translation, substitute?: boolean, hideInAnswer?: boolean }[] }): InputElement { diff --git a/test.ts b/test.ts index b84c509497..3b16ca3e49 100644 --- a/test.ts +++ b/test.ts @@ -1,15 +1,32 @@ //* - import OpeningHoursPickerTable from "./UI/Input/OpeningHours/OpeningHoursPickerTable"; import {UIElement} from "./UI/UIElement"; import {UIEventSource} from "./Logic/UIEventSource"; import {OpeningHour} from "./Logic/OpeningHours"; +import {TagRendering} from "./UI/Popup/TagRendering"; +import {Tag} from "./Logic/Tags"; -new OpeningHoursPickerTable(new UIEventSource([]), new UIEventSource([])) - .AttachTo("maindiv") +const tr = new TagRendering( + new UIEventSource({ + id: "node/-1", + amenity: "bench" + }), + { + question: "Does this bench have a backrest?", + mappings: [{ + k: new Tag("backrest", "yes"), + txt: "Has backrest" + }, + { + k: new Tag("backrest", "no"), + txt: "Has no backrest" + }] + } +) +tr.AttachTo("maindiv") /*/