forked from MapComplete/MapComplete
Merge branch 'develop' into feature/maproulette
This commit is contained in:
commit
64560b9cd2
279 changed files with 13050 additions and 4684 deletions
|
@ -520,6 +520,15 @@ export class ValidateLayer extends DesugaringStep<LayerConfigJson> {
|
|||
errors
|
||||
}
|
||||
}
|
||||
|
||||
if(json.tagRenderings !== undefined && json.tagRenderings.length > 0){
|
||||
if(json.title === undefined){
|
||||
errors.push(context + ": this layer does not have a title defined but it does have tagRenderings. Not having a title will disable the popups, resulting in an unclickable element. Please add a title. If not having a popup is intended and the tagrenderings need to be kept (e.g. in a library layer), set `title: null` to disable this error.")
|
||||
}
|
||||
if(json.title === null){
|
||||
information.push(context + ": title is `null`. This results in an element that cannot be clicked - even though tagRenderings is set.")
|
||||
}
|
||||
}
|
||||
|
||||
if (json["builtin"] !== undefined) {
|
||||
errors.push(context + ": This layer hasn't been expanded: " + json)
|
||||
|
|
|
@ -25,6 +25,11 @@ export interface TagRenderingConfigJson {
|
|||
*/
|
||||
labels?: string[]
|
||||
|
||||
/**
|
||||
* A human-readable text explaining what this tagRendering does
|
||||
*/
|
||||
description?: string | any
|
||||
|
||||
/**
|
||||
* Renders this value. Note that "{key}"-parts are substituted by the corresponding values of the element.
|
||||
* If neither 'textFieldQuestion' nor 'mappings' are defined, this text is simply shown as default value.
|
||||
|
|
|
@ -28,6 +28,9 @@ import {And} from "../../Logic/Tags/And";
|
|||
import {Overpass} from "../../Logic/Osm/Overpass";
|
||||
import Constants from "../Constants";
|
||||
import {FixedUiElement} from "../../UI/Base/FixedUiElement";
|
||||
import Svg from "../../Svg";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {OsmTags} from "../OsmFeature";
|
||||
|
||||
export default class LayerConfig extends WithContextLoader {
|
||||
|
||||
|
@ -191,8 +194,8 @@ export default class LayerConfig extends WithContextLoader {
|
|||
this.doNotDownload = json.doNotDownload ?? false;
|
||||
this.passAllFeatures = json.passAllFeatures ?? false;
|
||||
this.minzoom = json.minzoom ?? 0;
|
||||
if(json["minZoom"] !== undefined){
|
||||
throw "At "+context+": minzoom is written all lowercase"
|
||||
if (json["minZoom"] !== undefined) {
|
||||
throw "At " + context + ": minzoom is written all lowercase"
|
||||
}
|
||||
this.minzoomVisible = json.minzoomVisible ?? this.minzoom;
|
||||
this.shownByDefault = json.shownByDefault ?? true;
|
||||
|
@ -352,7 +355,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
neededLayer: string;
|
||||
}[] = []
|
||||
, addedByDefault = false, canBeIncluded = true): BaseUIElement {
|
||||
const extraProps = []
|
||||
const extraProps : (string | BaseUIElement)[] = []
|
||||
|
||||
extraProps.push("This layer is shown at zoomlevel **" + this.minzoom + "** and higher")
|
||||
|
||||
|
@ -364,9 +367,9 @@ export default class LayerConfig extends WithContextLoader {
|
|||
extraProps.push('This layer is not visible by default and must be enabled in the filter by the user. ')
|
||||
}
|
||||
if (this.title === undefined) {
|
||||
extraProps.push("This layer cannot be toggled in the filter view. If you import this layer in your theme, override `title` to make this toggleable.")
|
||||
extraProps.push("Elements don't have a title set and cannot be toggled nor will they show up in the dashboard. If you import this layer in your theme, override `title` to make this toggleable.")
|
||||
}
|
||||
if (this.title === undefined && this.shownByDefault === false) {
|
||||
if (this.name === undefined && this.shownByDefault === false) {
|
||||
extraProps.push("This layer is not visible by default and the visibility cannot be toggled, effectively resulting in a fully hidden layer. This can be useful, e.g. to calculate some metatags. If you want to render this layer (e.g. for debugging), enable it by setting the URL-parameter layer-<id>=true")
|
||||
}
|
||||
if (this.name === undefined) {
|
||||
|
@ -377,7 +380,11 @@ export default class LayerConfig extends WithContextLoader {
|
|||
}
|
||||
|
||||
if (this.source.geojsonSource !== undefined) {
|
||||
extraProps.push("<img src='../warning.svg' height='1rem'/> This layer is loaded from an external source, namely `" + this.source.geojsonSource + "`")
|
||||
extraProps.push(
|
||||
new Combine([
|
||||
Utils.runningFromConsole ? "<img src='../warning.svg' height='1rem'/>" : undefined,
|
||||
"This layer is loaded from an external source, namely ",
|
||||
new FixedUiElement( this.source.geojsonSource).SetClass("code")]));
|
||||
}
|
||||
} else {
|
||||
extraProps.push("This layer can **not** be included in a theme. It is solely used by [special renderings](SpecialRenderings.md) showing a minimap with custom data.")
|
||||
|
@ -409,16 +416,16 @@ export default class LayerConfig extends WithContextLoader {
|
|||
if (values == undefined) {
|
||||
return undefined
|
||||
}
|
||||
const embedded: (Link | string)[] = values.values?.map(v => Link.OsmWiki(values.key, v, true)) ?? ["_no preset options defined, or no values in them_"]
|
||||
const embedded: (Link | string)[] = values.values?.map(v => Link.OsmWiki(values.key, v, true).SetClass("mr-2")) ?? ["_no preset options defined, or no values in them_"]
|
||||
return [
|
||||
new Combine([
|
||||
new Link(
|
||||
"<img src='https://mapcomplete.osm.be/assets/svg/statistics.svg' height='18px'>",
|
||||
"https://taginfo.openstreetmap.org/keys/" + values.key + "#values"
|
||||
Utils.runningFromConsole ? "<img src='https://mapcomplete.osm.be/assets/svg/statistics.svg' height='18px'>" : Svg.statistics_svg().SetClass("w-4 h-4 mr-2"),
|
||||
"https://taginfo.openstreetmap.org/keys/" + values.key + "#values", true
|
||||
), Link.OsmWiki(values.key)
|
||||
]),
|
||||
]).SetClass("flex"),
|
||||
values.type === undefined ? "Multiple choice" : new Link(values.type, "../SpecialInputElements.md#" + values.type),
|
||||
new Combine(embedded)
|
||||
new Combine(embedded).SetClass("flex")
|
||||
];
|
||||
}))
|
||||
|
||||
|
@ -427,18 +434,27 @@ export default class LayerConfig extends WithContextLoader {
|
|||
quickOverview = new Combine([
|
||||
new FixedUiElement("Warning: ").SetClass("bold"),
|
||||
"this quick overview is incomplete",
|
||||
new Table(["attribute", "type", "values which are supported by this layer"], tableRows)
|
||||
new Table(["attribute", "type", "values which are supported by this layer"], tableRows).SetClass("zebra-table")
|
||||
]).SetClass("flex-col flex")
|
||||
}
|
||||
|
||||
const icon = this.mapRendering
|
||||
.filter(mr => mr.location.has("point"))
|
||||
.map(mr => mr.icon?.render?.txt)
|
||||
.find(i => i !== undefined)
|
||||
let iconImg = ""
|
||||
if (icon !== undefined) {
|
||||
// This is for the documentation, so we have to use raw HTML
|
||||
iconImg = `<img src='https://mapcomplete.osm.be/${icon}' height="100px"> `
|
||||
|
||||
let iconImg: BaseUIElement = new FixedUiElement("")
|
||||
|
||||
if (Utils.runningFromConsole) {
|
||||
const icon = this.mapRendering
|
||||
.filter(mr => mr.location.has("point"))
|
||||
.map(mr => mr.icon?.render?.txt)
|
||||
.find(i => i !== undefined)
|
||||
// This is for the documentation in a markdown-file, so we have to use raw HTML
|
||||
if (icon !== undefined) {
|
||||
iconImg = new FixedUiElement(`<img src='https://mapcomplete.osm.be/${icon}' height="100px"> `)
|
||||
}
|
||||
} else {
|
||||
iconImg = this.mapRendering
|
||||
.filter(mr => mr.location.has("point"))
|
||||
.map(mr => mr.GenerateLeafletStyle(new UIEventSource<OsmTags>({id:"node/-1"}), false, {includeBadges: false}).html)
|
||||
.find(i => i !== undefined)
|
||||
}
|
||||
|
||||
let overpassLink: BaseUIElement = undefined;
|
||||
|
@ -467,7 +483,7 @@ export default class LayerConfig extends WithContextLoader {
|
|||
new Title("Supported attributes", 2),
|
||||
quickOverview,
|
||||
...this.tagRenderings.map(tr => tr.GenerateDocumentation())
|
||||
]).SetClass("flex-col")
|
||||
]).SetClass("flex-col").SetClass("link-underline")
|
||||
}
|
||||
|
||||
public CustomCodeSnippets(): string[] {
|
||||
|
|
|
@ -14,6 +14,8 @@ import List from "../../UI/Base/List";
|
|||
import {MappingConfigJson, QuestionableTagRenderingConfigJson} from "./Json/QuestionableTagRenderingConfigJson";
|
||||
import {FixedUiElement} from "../../UI/Base/FixedUiElement";
|
||||
import {Paragraph} from "../../UI/Base/Paragraph";
|
||||
import spec = Mocha.reporters.spec;
|
||||
import SpecialVisualizations from "../../UI/SpecialVisualizations";
|
||||
|
||||
export interface Mapping {
|
||||
readonly if: TagsFilter,
|
||||
|
@ -38,6 +40,7 @@ export default class TagRenderingConfig {
|
|||
public readonly render?: TypedTranslation<object>;
|
||||
public readonly question?: TypedTranslation<object>;
|
||||
public readonly condition?: TagsFilter;
|
||||
public readonly description?: Translation;
|
||||
|
||||
public readonly configuration_warnings: string[] = []
|
||||
|
||||
|
@ -56,6 +59,7 @@ export default class TagRenderingConfig {
|
|||
public readonly mappings?: Mapping[]
|
||||
public readonly labels: string[]
|
||||
|
||||
|
||||
constructor(json: string | QuestionableTagRenderingConfigJson, context?: string) {
|
||||
if (json === undefined) {
|
||||
throw "Initing a TagRenderingConfig with undefined in " + context;
|
||||
|
@ -107,6 +111,7 @@ export default class TagRenderingConfig {
|
|||
this.labels = json.labels ?? []
|
||||
this.render = Translations.T(json.render, translationKey + ".render");
|
||||
this.question = Translations.T(json.question, translationKey + ".question");
|
||||
this.description = Translations.T(json.description, translationKey + ".description");
|
||||
this.condition = TagUtils.Tag(json.condition ?? {"and": []}, `${context}.condition`);
|
||||
if (json.freeform) {
|
||||
|
||||
|
@ -571,8 +576,8 @@ export default class TagRenderingConfig {
|
|||
new Combine(
|
||||
[
|
||||
new FixedUiElement(m.then.txt).SetClass("bold"),
|
||||
"corresponds with ",
|
||||
m.if.asHumanString(true, false, {})
|
||||
" corresponds with ",
|
||||
new FixedUiElement( m.if.asHumanString(true, false, {})).SetClass("code")
|
||||
]
|
||||
)
|
||||
]
|
||||
|
@ -607,12 +612,14 @@ export default class TagRenderingConfig {
|
|||
labels = new Combine([
|
||||
"This tagrendering has labels ",
|
||||
...this.labels.map(label => new FixedUiElement(label).SetClass("code"))
|
||||
])
|
||||
]).SetClass("flex")
|
||||
}
|
||||
|
||||
return new Combine([
|
||||
new Title(this.id, 3),
|
||||
this.description,
|
||||
this.question !== undefined ?
|
||||
new Combine(["The question is ", new FixedUiElement(this.question.txt).SetClass("bold")]) :
|
||||
new Combine(["The question is ", new FixedUiElement(this.question.txt).SetClass("font-bold bold")]) :
|
||||
new FixedUiElement(
|
||||
"This tagrendering has no question and is thus read-only"
|
||||
).SetClass("italic"),
|
||||
|
@ -621,6 +628,6 @@ export default class TagRenderingConfig {
|
|||
condition,
|
||||
group,
|
||||
labels
|
||||
]).SetClass("flex-col");
|
||||
]).SetClass("flex flex-col");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue