2020-10-14 12:15:09 +02:00
|
|
|
import {UIElement} from "../UIElement";
|
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
2020-10-27 01:01:34 +01:00
|
|
|
import LayerConfig from "../../Customizations/JSON/LayerConfig";
|
|
|
|
import EditableTagRendering from "./EditableTagRendering";
|
|
|
|
import QuestionBox from "./QuestionBox";
|
|
|
|
import Combine from "../Base/Combine";
|
|
|
|
import TagRenderingAnswer from "./TagRenderingAnswer";
|
2020-11-12 12:18:02 +01:00
|
|
|
import State from "../../State";
|
2021-01-07 04:50:12 +01:00
|
|
|
import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
|
2021-01-08 02:13:44 +01:00
|
|
|
import ScrollableFullScreen from "../Base/ScrollableFullScreen";
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2021-01-04 04:06:21 +01:00
|
|
|
export default class FeatureInfoBox extends UIElement {
|
2021-01-08 02:13:44 +01:00
|
|
|
private _component: UIElement;
|
2020-07-22 00:18:07 +02:00
|
|
|
|
2021-01-09 02:11:43 +01:00
|
|
|
public title: UIElement ;
|
2021-01-08 18:02:07 +01:00
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
constructor(
|
2020-10-27 01:01:34 +01:00
|
|
|
tags: UIEventSource<any>,
|
|
|
|
layerConfig: LayerConfig
|
2020-06-27 03:06:51 +02:00
|
|
|
) {
|
2020-10-27 01:01:34 +01:00
|
|
|
super();
|
2020-11-17 16:29:51 +01:00
|
|
|
if (layerConfig === undefined) {
|
2020-11-02 18:59:21 +01:00
|
|
|
throw "Undefined layerconfig"
|
|
|
|
}
|
2020-06-27 03:06:51 +02:00
|
|
|
|
2020-09-13 00:53:24 +02:00
|
|
|
|
2021-01-08 03:57:18 +01:00
|
|
|
const title = new TagRenderingAnswer(tags, layerConfig.title ?? new TagRenderingConfig("POI", undefined))
|
2021-01-07 04:50:12 +01:00
|
|
|
.SetClass("featureinfobox-title");
|
2021-01-08 18:02:07 +01:00
|
|
|
this.title = title;
|
2021-01-08 02:13:44 +01:00
|
|
|
const titleIcons = new Combine(
|
2020-10-27 01:01:34 +01:00
|
|
|
layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon)))
|
|
|
|
.SetClass("featureinfobox-icons");
|
2021-01-04 04:06:21 +01:00
|
|
|
|
|
|
|
let questionBox: UIElement = undefined;
|
2020-11-12 12:21:34 +01:00
|
|
|
if (State.state.featureSwitchUserbadge.data) {
|
2020-12-08 23:44:34 +01:00
|
|
|
questionBox = new QuestionBox(tags, layerConfig.tagRenderings);
|
2020-11-12 12:21:34 +01:00
|
|
|
}
|
2021-01-04 04:06:21 +01:00
|
|
|
|
2020-12-08 23:44:34 +01:00
|
|
|
let questionBoxIsUsed = false;
|
2021-01-08 02:13:44 +01:00
|
|
|
const renderings = layerConfig.tagRenderings.map(tr => {
|
2021-01-04 04:06:21 +01:00
|
|
|
if (tr.question === null) {
|
2020-12-08 23:44:34 +01:00
|
|
|
questionBoxIsUsed = true;
|
|
|
|
// This is the question box!
|
|
|
|
return questionBox;
|
|
|
|
}
|
|
|
|
return new EditableTagRendering(tags, tr);
|
|
|
|
});
|
2021-01-08 02:13:44 +01:00
|
|
|
renderings[0]?.SetClass("first-rendering");
|
2021-01-04 04:06:21 +01:00
|
|
|
if (!questionBoxIsUsed) {
|
2021-01-08 02:13:44 +01:00
|
|
|
renderings.push(questionBox);
|
2021-01-04 04:06:21 +01:00
|
|
|
}
|
2021-01-08 16:49:42 +01:00
|
|
|
const tail = new Combine([]).SetClass("only-on-mobile");
|
2021-01-08 02:13:44 +01:00
|
|
|
|
|
|
|
const content = new Combine([
|
|
|
|
...renderings,
|
|
|
|
tail.SetClass("featureinfobox-tail")
|
|
|
|
]
|
|
|
|
)
|
|
|
|
const titleBar = new Combine([
|
|
|
|
new Combine([title, titleIcons]).SetClass("featureinfobox-titlebar-title")
|
|
|
|
])
|
|
|
|
|
|
|
|
this._component = new ScrollableFullScreen(titleBar, content)
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
InnerRender(): string {
|
2021-01-08 02:13:44 +01:00
|
|
|
return this._component.Render();
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|
2020-07-20 15:54:50 +02:00
|
|
|
|
2020-06-27 03:06:51 +02:00
|
|
|
}
|