Further improvements to entrances theme, add layer-crossdependency detection, add layers which another layer depends on automatically to the theme, add documentation on which layers depends on which other layers, regenerate documentation

This commit is contained in:
Pieter Vander Vennet 2021-12-05 02:06:14 +01:00
parent 8e40d76281
commit 0ee23ce36d
27 changed files with 9032 additions and 331 deletions

View file

@ -1,5 +1,6 @@
import BaseUIElement from "../BaseUIElement";
import {FixedUiElement} from "./FixedUiElement";
import {Utils} from "../../Utils";
export default class Title extends BaseUIElement {
public readonly title: BaseUIElement;
@ -10,6 +11,9 @@ export default class Title extends BaseUIElement {
constructor(embedded: string | BaseUIElement, level: number = 3) {
super()
if(embedded === undefined){
throw "A title should have some content. Undefined is not allowed"
}
if (typeof embedded === "string") {
this.title = new FixedUiElement(embedded)
} else {
@ -23,7 +27,11 @@ export default class Title extends BaseUIElement {
}else if(embedded instanceof FixedUiElement){
innerText = embedded.content
}else{
this.title.ConstructElement()?.innerText
if(Utils.runningFromConsole){
console.log("Not constructing an anchor for title with embedded content of "+embedded)
}else{
innerText = embedded.ConstructElement()?.innerText
}
}
this.id = innerText?.replace(/ /g, '-')

View file

@ -140,6 +140,20 @@ ${Utils.Special_visualizations_tagsToApplyHelpText}
defaultValue: "5"
}]
getLayerDependencies(args: string[]){
const dependsOnLayers: string[] = []
// The target layer
dependsOnLayers.push(args[0])
const snapOntoLayers = args[5]?.trim() ?? "";
if(args[5] !== ""){
dependsOnLayers.push(...snapOntoLayers.split(";"))
}
return dependsOnLayers
}
constr(state, tagSource, args, guiState) {
if (!state.layoutToUse.official && !(state.featureSwitchIsTesting.data || state.osmConnection._oauth_config.url === OsmConnection.oauth_configs["osm-test"].url)) {
return new Combine([new FixedUiElement("The import button is disabled for unofficial themes to prevent accidents.").SetClass("alert"),

View file

@ -44,7 +44,8 @@ export interface SpecialVisualization {
constr: ((state: State, tagSource: UIEventSource<any>, argument: string[], guistate: DefaultGuiState,) => BaseUIElement),
docs: string,
example?: string,
args: { name: string, defaultValue?: string, doc: string }[]
args: { name: string, defaultValue?: string, doc: string }[],
getLayerDependencies?: (argument: string[]) => string[]
}
export default class SpecialVisualizations {
@ -477,6 +478,7 @@ export default class SpecialVisualizations {
}
},
new ImportButtonSpecialViz(),
{
funcName: "multi_apply",
docs: "A button to apply the tagging of this object onto a list of other features. This is an advanced feature for which you'll need calculatedTags",
@ -688,7 +690,7 @@ export default class SpecialVisualizations {
return [arg.name, defaultArg, arg.doc];
})
) : undefined,
new Title("Example usage", 4),
new Title("Example usage of "+viz.funcName, 4),
new FixedUiElement(
viz.example ?? "`{" + viz.funcName + "(" + viz.args.map(arg => arg.defaultValue).join(",") + ")}`"
).SetClass("literal-code"),

View file

@ -112,6 +112,10 @@ export class Translation extends BaseUIElement {
}
return langs;
}
public AllValues(): string[]{
return this.SupportedLanguages().map(lng => this.translations[lng]);
}
public Subs(text: any): Translation {
const newTranslations = {};