MapComplete/UI/Popup/FeatureInfoBox.ts

50 lines
1.7 KiB
TypeScript
Raw Normal View History

import { UIEventSource } from "../../Logic/UIEventSource"
2022-09-08 21:40:48 +02:00
import Combine from "../Base/Combine"
import ScrollableFullScreen from "../Base/ScrollableFullScreen"
import BaseUIElement from "../BaseUIElement"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
import Toggle from "../Input/Toggle"
import FeaturePipelineState from "../../Logic/State/FeaturePipelineState"
2022-11-08 14:37:48 +01:00
import Svg from "../../Svg"
import Translations from "../i18n/Translations"
export default class FeatureInfoBox extends ScrollableFullScreen {
2021-06-14 02:39:23 +02:00
public constructor(
2020-10-27 01:01:34 +01:00
tags: UIEventSource<any>,
layerConfig: LayerConfig,
2022-05-01 04:17:40 +02:00
state: FeaturePipelineState,
2022-07-08 03:14:55 +02:00
options?: {
2022-09-08 21:40:48 +02:00
hashToShow?: string
isShown?: UIEventSource<boolean>
2022-07-08 03:14:55 +02:00
setHash?: true | boolean
}
) {
const showAllQuestions = state.featureSwitchShowAllQuestions.map(
(fsShow) => fsShow || state.showAllQuestionsAtOnce.data,
[state.showAllQuestionsAtOnce]
)
2022-09-08 21:40:48 +02:00
super(
2023-04-14 04:34:13 +02:00
() => undefined,
() => FeatureInfoBox.GenerateContent(tags, layerConfig),
2022-07-08 03:14:55 +02:00
options?.hashToShow ?? tags.data.id ?? "item",
options?.isShown,
2022-09-08 21:40:48 +02:00
options
)
2020-11-17 16:29:51 +01:00
if (layerConfig === undefined) {
2022-09-08 21:40:48 +02:00
throw "Undefined layerconfig"
2020-11-02 18:59:21 +01:00
}
2021-01-25 03:12:09 +01:00
}
public static GenerateContent(tags: UIEventSource<any>): BaseUIElement {
return new Toggle(
2022-12-16 13:45:07 +01:00
new Combine([
Svg.delete_icon_svg().SetClass("w-8 h-8"),
Translations.t.delete.isDeleted,
]).SetClass("flex justify-center font-bold items-center"),
new Combine([]).SetClass("block"),
2022-12-16 13:45:07 +01:00
tags.map((t) => t["_deleted"] == "yes")
)
}
}