Reformat all files with prettier

This commit is contained in:
Pieter Vander Vennet 2022-09-08 21:40:48 +02:00
parent e22d189376
commit b541d3eab4
382 changed files with 50893 additions and 35566 deletions

View file

@ -1,61 +1,78 @@
import {UIEventSource} from "../../Logic/UIEventSource";
import {Utils} from "../../Utils";
import BaseUIElement from "../BaseUIElement";
import {VariableUiElement} from "../Base/VariableUIElement";
import {SubstitutedTranslation} from "../SubstitutedTranslation";
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig";
import Combine from "../Base/Combine";
import Img from "../Base/Img";
import { UIEventSource } from "../../Logic/UIEventSource"
import { Utils } from "../../Utils"
import BaseUIElement from "../BaseUIElement"
import { VariableUiElement } from "../Base/VariableUIElement"
import { SubstitutedTranslation } from "../SubstitutedTranslation"
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
import Combine from "../Base/Combine"
import Img from "../Base/Img"
/***
* Displays the correct value for a known tagrendering
*/
export default class TagRenderingAnswer extends VariableUiElement {
constructor(tagsSource: UIEventSource<any>, configuration: TagRenderingConfig,
state: any,
contentClasses: string = "", contentStyle: string = "", options?: {
constructor(
tagsSource: UIEventSource<any>,
configuration: TagRenderingConfig,
state: any,
contentClasses: string = "",
contentStyle: string = "",
options?: {
specialViz: Map<string, BaseUIElement>
}) {
}
) {
if (configuration === undefined) {
throw "Trying to generate a tagRenderingAnswer without configuration..."
}
if (tagsSource === undefined) {
throw "Trying to generate a tagRenderingAnswer without tagSource..."
}
super(tagsSource.map(tags => {
if (tags === undefined) {
return undefined;
}
super(
tagsSource
.map((tags) => {
if (tags === undefined) {
return undefined
}
if (configuration.condition) {
if (!configuration.condition.matchesProperties(tags)) {
return undefined;
}
}
if (configuration.condition) {
if (!configuration.condition.matchesProperties(tags)) {
return undefined
}
}
const trs = Utils.NoNull(configuration.GetRenderValues(tags));
if (trs.length === 0) {
return undefined;
}
const trs = Utils.NoNull(configuration.GetRenderValues(tags))
if (trs.length === 0) {
return undefined
}
const valuesToRender: BaseUIElement[] = trs.map(tr => {
const text = new SubstitutedTranslation(tr.then, tagsSource, state, options?.specialViz);
if(tr.icon === undefined){
return text
}
return new Combine([new Img(tr.icon).SetClass("mapping-icon-"+(tr.iconClass ?? "small")), text]).SetClass("flex items-center")
})
if (valuesToRender.length === 1) {
return valuesToRender[0];
} else if (valuesToRender.length > 1) {
return new Combine(valuesToRender).SetClass("flex flex-col")
}
return undefined;
}).map((element: BaseUIElement) => element?.SetClass(contentClasses)?.SetStyle(contentStyle)))
const valuesToRender: BaseUIElement[] = trs.map((tr) => {
const text = new SubstitutedTranslation(
tr.then,
tagsSource,
state,
options?.specialViz
)
if (tr.icon === undefined) {
return text
}
return new Combine([
new Img(tr.icon).SetClass("mapping-icon-" + (tr.iconClass ?? "small")),
text,
]).SetClass("flex items-center")
})
if (valuesToRender.length === 1) {
return valuesToRender[0]
} else if (valuesToRender.length > 1) {
return new Combine(valuesToRender).SetClass("flex flex-col")
}
return undefined
})
.map((element: BaseUIElement) =>
element?.SetClass(contentClasses)?.SetStyle(contentStyle)
)
)
this.SetClass("flex items-center flex-row text-lg link-underline")
this.SetStyle("word-wrap: anywhere;");
this.SetStyle("word-wrap: anywhere;")
}
}
}