forked from MapComplete/MapComplete
Various bug fixes and updates
This commit is contained in:
parent
97ec893479
commit
e069b31e4e
29 changed files with 482 additions and 148 deletions
|
@ -10,6 +10,8 @@ import {UserDetails} from "../../Logic/Osm/OsmConnection";
|
|||
import {MultiInput} from "../Input/MultiInput";
|
||||
import TagRenderingPanel from "./TagRenderingPanel";
|
||||
import SingleSetting from "./SingleSetting";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
import {FromJSON} from "../../Customizations/JSON/FromJSON";
|
||||
|
||||
export default class AllLayersPanel extends UIElement {
|
||||
|
||||
|
@ -49,9 +51,22 @@ export default class AllLayersPanel extends UIElement {
|
|||
|
||||
const layers = this._config.data.layers;
|
||||
for (let i = 0; i < layers.length; i++) {
|
||||
|
||||
tabs.push({
|
||||
header: "<img src='./assets/bug.svg'>",
|
||||
header: new VariableUiElement(this._config.map((config: LayoutConfigJson) => {
|
||||
const layer = config.layers[i];
|
||||
if (typeof layer !== "string") {
|
||||
try {
|
||||
const iconTagRendering = FromJSON.TagRendering(layer.icon, "icon");
|
||||
const icon = iconTagRendering.GetContent({"id": "node/-1"}).txt;
|
||||
return `<img src='${icon}'>`
|
||||
} catch (e) {
|
||||
return "<img src='./assets/bug.svg'>"
|
||||
// Nothing to do here
|
||||
}
|
||||
}
|
||||
return "<img src='./assets/help.svg'>"
|
||||
|
||||
})),
|
||||
content: new LayerPanelWithPreview(this._config, this.languages, i, userDetails)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ export class GenerateEmpty {
|
|||
title: {},
|
||||
description: {},
|
||||
tagRenderings: [],
|
||||
hideUnderlayingFeaturesMinPercentage: 0,
|
||||
icon: {
|
||||
render: "./assets/bug.svg"
|
||||
},
|
||||
|
|
|
@ -96,7 +96,10 @@ export default class LayerPanel extends UIElement {
|
|||
{value: 2, shown: "Show both the ways/areas and the centerpoints"},
|
||||
{value: 1, shown: "Show everything as centerpoint"}]), "wayHandling", "Way handling",
|
||||
"Describes how ways and areas are represented on the map: areas can be represented as the area itself, or it can be converted into the centerpoint"),
|
||||
|
||||
setting(TextField.NumberInput("nat", n => n <= 100), "hideUnderlayingFeaturesMinPercentage", "Max allowed overlap percentage",
|
||||
"Consider that we want to show 'Nature Reserves' and 'Forests'. Now, ofter, there are pieces of forest mapped _in_ the nature reserve.<br/>" +
|
||||
"Now, showing those pieces of forest overlapping with the nature reserve truly clutters the map and is very user-unfriendly.<br/>" +
|
||||
"The features are placed layer by layer. If a feature below a feature on this layer overlaps for more then 'x'-percent, the underlying feature is hidden."),
|
||||
setting(new AndOrTagInput(), "overpassTags", "Overpass query",
|
||||
"The tags of the objects to load from overpass"),
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import {UserDetails} from "../../Logic/Osm/OsmConnection";
|
|||
|
||||
export default class LayerPanelWithPreview extends UIElement{
|
||||
private panel: UIElement;
|
||||
|
||||
constructor(config: UIEventSource<any>, languages: UIEventSource<string[]>, index: number, userDetails: UserDetails) {
|
||||
super();
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ export default class TagRenderingPanel extends InputElement<TagRenderingConfigJs
|
|||
|
||||
"<h3>Mappings</h3>",
|
||||
setting(new MultiInput<{ if: AndOrTagConfigJson, then: (string | any), hideInAnswer?: boolean }>("Add a mapping",
|
||||
() => ({if: undefined, then: undefined}),
|
||||
() => ({if: {and: []}, then: {}}),
|
||||
() => new MappingInput(languages, options?.disableQuestions ?? false),
|
||||
undefined, {allowMovement: true}), "mappings",
|
||||
"If a tag matches, then show the first respective text", "")
|
||||
|
|
|
@ -7,9 +7,13 @@ export class FixedInputElement<T> extends InputElement<T> {
|
|||
private readonly rendering: UIElement;
|
||||
private readonly value: UIEventSource<T>;
|
||||
public readonly IsSelected : UIEventSource<boolean> = new UIEventSource<boolean>(false);
|
||||
private readonly _comparator: (t0: T, t1: T) => boolean;
|
||||
|
||||
constructor(rendering: UIElement | string, value: T) {
|
||||
constructor(rendering: UIElement | string,
|
||||
value: T,
|
||||
comparator: ((t0: T, t1: T) => boolean ) = undefined) {
|
||||
super(undefined);
|
||||
this._comparator = comparator ?? ((t0, t1) => t0 == t1);
|
||||
this.value = new UIEventSource<T>(value);
|
||||
this.rendering = typeof (rendering) === 'string' ? new FixedUiElement(rendering) : rendering;
|
||||
}
|
||||
|
@ -22,7 +26,9 @@ export class FixedInputElement<T> extends InputElement<T> {
|
|||
}
|
||||
|
||||
IsValid(t: T): boolean {
|
||||
return t == this.value.data;
|
||||
|
||||
console.log("Comparing ",t, "with", this.value.data);
|
||||
return this._comparator(t, this.value.data);
|
||||
}
|
||||
|
||||
protected InnerUpdate(htmlElement: HTMLElement) {
|
||||
|
|
|
@ -8,14 +8,15 @@ export class RadioButton<T> extends InputElement<T> {
|
|||
private readonly _selectedElementIndex: UIEventSource<number>
|
||||
= new UIEventSource<number>(null);
|
||||
|
||||
private value: UIEventSource<T>;
|
||||
private readonly value: UIEventSource<T>;
|
||||
private readonly _elements: InputElement<T>[]
|
||||
private _selectFirstAsDefault: boolean;
|
||||
private readonly _selectFirstAsDefault: boolean;
|
||||
|
||||
|
||||
constructor(elements: InputElement<T>[],
|
||||
selectFirstAsDefault = true) {
|
||||
super(undefined);
|
||||
console.log("Created new radiobutton with values ", elements)
|
||||
this._elements = Utils.NoNull(elements);
|
||||
this._selectFirstAsDefault = selectFirstAsDefault;
|
||||
const self = this;
|
||||
|
|
|
@ -54,6 +54,9 @@ export class SimpleAddUI extends UIElement {
|
|||
if (typeof (preset.icon) !== "string") {
|
||||
const tags = Utils.MergeTags(TagUtils.KVtoProperties(preset.tags), {id:"node/-1"});
|
||||
icon = preset.icon.GetContent(tags).txt;
|
||||
if(icon.startsWith("$")){
|
||||
icon = undefined;
|
||||
}
|
||||
} else {
|
||||
icon = preset.icon;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ export abstract class UIElement extends UIEventSource<string> {
|
|||
private _hideIfEmpty = false;
|
||||
|
||||
public dumbMode = false;
|
||||
|
||||
private lastInnerRender: string;
|
||||
|
||||
/**
|
||||
* In the 'deploy'-step, some code needs to be run by ts-node.
|
||||
|
@ -37,6 +39,7 @@ export abstract class UIElement extends UIEventSource<string> {
|
|||
this.dumbMode = false;
|
||||
const self = this;
|
||||
source.addCallback(() => {
|
||||
self.lastInnerRender = undefined;
|
||||
self.Update();
|
||||
})
|
||||
return this;
|
||||
|
@ -92,7 +95,7 @@ export abstract class UIElement extends UIEventSource<string> {
|
|||
|
||||
return;
|
||||
}
|
||||
this.setData(this.InnerRender());
|
||||
this.setData(this.lastInnerRender ?? this.InnerRender());
|
||||
element.innerHTML = this.data;
|
||||
|
||||
if (this._hideIfEmpty) {
|
||||
|
@ -151,14 +154,15 @@ export abstract class UIElement extends UIEventSource<string> {
|
|||
}
|
||||
|
||||
Render(): string {
|
||||
this.lastInnerRender = this.lastInnerRender ?? this.InnerRender();
|
||||
if (this.dumbMode) {
|
||||
return this.InnerRender();
|
||||
return this.lastInnerRender;
|
||||
}
|
||||
let style = "";
|
||||
if (this.style !== undefined && this.style !== "") {
|
||||
style = `style="${this.style}"`;
|
||||
}
|
||||
return `<span class='uielement ${this.clss.join(" ")}' ${style} id='${this.id}'>${this.InnerRender()}</span>`
|
||||
return `<span class='uielement ${this.clss.join(" ")}' ${style} id='${this.id}'>${this.lastInnerRender}</span>`
|
||||
}
|
||||
|
||||
AttachTo(divId: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue