New roaming rendering system which allows layers to push questions, badges and title-icons to all the other layers, improve bike-clean-services

This commit is contained in:
Pieter Vander Vennet 2021-01-08 03:57:18 +01:00
parent 77ffdc093a
commit 2a31badd3d
16 changed files with 427 additions and 394 deletions

View file

@ -68,7 +68,7 @@ export default class AllLayersPanel extends UIElement {
const layer = config.layers[i];
if (typeof layer !== "string") {
try {
const iconTagRendering = new TagRenderingConfig(layer.icon, "icon")
const iconTagRendering = new TagRenderingConfig(layer.icon, undefined, "icon")
const icon = iconTagRendering.GetRenderValue({"id": "node/-1"}).txt;
return `<img src='${icon}'>`
} catch (e) {

View file

@ -111,7 +111,7 @@ export default class TagRenderingPanel extends InputElement<TagRenderingConfigJs
this.validText = new VariableUiElement(value.map((json: TagRenderingConfigJson) => {
try{
new TagRenderingConfig(json, options?.title ?? "");
new TagRenderingConfig(json,undefined, options?.title ?? "");
return "";
}catch(e){
return "<span class='alert'>"+e+"</span>"

View file

@ -40,7 +40,7 @@ export default class TagRenderingPreview extends UIElement {
rendering =
new VariableUiElement(es.map(tagRenderingConfig => {
try {
const tr = new EditableTagRendering(self.previewTagValue, new TagRenderingConfig(tagRenderingConfig, "preview"));
const tr = new EditableTagRendering(self.previewTagValue, new TagRenderingConfig(tagRenderingConfig, undefined,"preview"));
return tr.Render();
} catch (e) {
return new Combine(["Could not show this tagrendering:", e.message]).Render();

View file

@ -25,7 +25,7 @@ export default class FeatureInfoBox extends UIElement {
}
const title = new TagRenderingAnswer(tags, layerConfig.title ?? new TagRenderingConfig("POI"))
const title = new TagRenderingAnswer(tags, layerConfig.title ?? new TagRenderingConfig("POI", undefined))
.SetClass("featureinfobox-title");
const titleIcons = new Combine(
layerConfig.titleIcons.map(icon => new TagRenderingAnswer(tags, icon)))
@ -53,7 +53,6 @@ export default class FeatureInfoBox extends UIElement {
const content = new Combine([
...renderings,
questionBox,
tail.SetClass("featureinfobox-tail")
]
)

View file

@ -67,7 +67,7 @@ export default class TagRenderingQuestion extends UIElement {
}
this._saveButton = new SaveButton(this._inputElement.GetValue(), State.state.osmConnection)
this._saveButton = new SaveButton(this._inputElement.GetValue(), State.state?.osmConnection)
.onClick(save)

View file

@ -4,12 +4,6 @@ import {Utils} from "../Utils";
export abstract class UIElement extends UIEventSource<string> {
/**
* In the 'deploy'-step, some code needs to be run by ts-node.
* However, ts-node crashes when it sees 'document'. When running from console, we flag this and disable all code where document is needed.
* This is a workaround and yet another hack
*/
public static runningFromConsole = false;
private static nextId: number = 0;
public readonly id: string;
public readonly _source: UIEventSource<any>;