Merge master

This commit is contained in:
Pieter Vander Vennet 2022-06-19 18:23:43 +02:00
commit 470e9acc64
66 changed files with 10798 additions and 414 deletions

View file

@ -26,9 +26,7 @@ export default class Title extends BaseUIElement {
} else if (embedded instanceof FixedUiElement) {
innerText = embedded.content
} else {
if (Utils.runningFromConsole) {
console.log("Not constructing an anchor for title with embedded content of " + embedded)
} else {
if (!Utils.runningFromConsole) {
innerText = embedded.ConstructElement()?.innerText
}
}

View file

@ -6,6 +6,10 @@ import FilteredLayer from "../../Models/FilteredLayer";
import {TagUtils} from "../../Logic/Tags/TagUtils";
import Svg from "../../Svg";
/**
* The icon with the 'plus'-sign and the preset icons spinning
*
*/
export default class AddNewMarker extends Combine {
constructor(filteredLayers: UIEventSource<FilteredLayer[]>) {

View file

@ -1,9 +1,10 @@
import Combine from "../Base/Combine";
import Attribution from "./Attribution";
import Img from "../Base/Img";
import ImageProvider, {ProvidedImage} from "../../Logic/ImageProviders/ImageProvider";
import ImageProvider from "../../Logic/ImageProviders/ImageProvider";
import BaseUIElement from "../BaseUIElement";
import {Mapillary} from "../../Logic/ImageProviders/Mapillary";
import {UIEventSource} from "../../Logic/UIEventSource";
export class AttributedImage extends Combine {
@ -21,7 +22,7 @@ export class AttributedImage extends Combine {
let attr: BaseUIElement = undefined
if(imageInfo.provider !== undefined){
attr = new Attribution(imageInfo.provider?.GetAttributionFor(imageInfo.url),
attr = new Attribution(UIEventSource.FromPromise( imageInfo.provider?.DownloadAttribution(imageInfo.url)),
imageInfo.provider?.SourceIcon(),
imageInfo.date
)

View file

@ -24,7 +24,7 @@ export default class Attribution extends VariableUiElement {
new Combine([
Translations.W(license?.title).SetClass("block"),
Translations.W(license?.artist ?? "").SetClass("block font-bold"),
Translations.W((license?.license ?? "") === "" ? "CC0" : (license?.license ?? "")),
Translations.W(license?.license ?? license?.licenseShortName),
date === undefined ? undefined : new FixedUiElement(date.toLocaleDateString())
]).SetClass("flex flex-col")
]).SetClass("flex flex-row bg-black text-white text-sm absolute bottom-0 left-0 p-0.5 pl-5 pr-3 rounded-lg no-images")

View file

@ -547,7 +547,7 @@ class LengthTextField extends TextFieldDef {
constructor() {
super(
"decimal", "A geographical length in meters (rounded at two points). Will give an extra minimap with a measurement tool. Arguments: [ zoomlevel, preferredBackgroundMapType (comma separated) ], e.g. `[\"21\", \"map,photo\"]"
"length", "A geographical length in meters (rounded at two points). Will give an extra minimap with a measurement tool. Arguments: [ zoomlevel, preferredBackgroundMapType (comma separated) ], e.g. `[\"21\", \"map,photo\"]"
)
}
@ -734,6 +734,7 @@ class EmailTextField extends TextFieldDef {
if (str === undefined) {
return false
}
str = str.trim()
if (str.startsWith("mailto:")) {
str = str.substring("mailto:".length)
}
@ -744,6 +745,7 @@ class EmailTextField extends TextFieldDef {
if (str === undefined) {
return undefined
}
str = str.trim()
if (str.startsWith("mailto:")) {
str = str.substring("mailto:".length)
}

View file

@ -69,7 +69,7 @@ export default class ConfirmLocationOfPoint extends Combine {
bounds: mapBounds
})
preciseInput.installBounds(preset.boundsFactor ?? 0.25, true)
preciseInput.SetClass("h-40 rounded-xl overflow-hidden border border-gray").SetStyle("height: 12rem;")
preciseInput.SetClass("rounded-xl overflow-hidden border border-gray").SetStyle("height: 18rem; max-height: 50vh")
if (preset.preciseInput.snapToLayers && preset.preciseInput.snapToLayers.length > 0) {

View file

@ -223,7 +223,9 @@ export default class FeatureInfoBox extends ScrollableFullScreen {
return new Combine([new TagRenderingAnswer(tags, config_all_tags, state),
new TagRenderingAnswer(tags, config_download, state),
new TagRenderingAnswer(tags, config_id, state)])
new TagRenderingAnswer(tags, config_id, state),
"This is layer "+layerConfig.id
])
}
})
)

View file

@ -54,11 +54,13 @@ abstract class AbstractImportButton implements SpecialVisualizations {
public readonly docs: string
public readonly args: { name: string, defaultValue?: string, doc: string }[]
private readonly showRemovedTags: boolean;
private readonly cannotBeImportedMessage: BaseUIElement | undefined;
constructor(funcName: string, docsIntro: string, extraArgs: { name: string, doc: string, defaultValue?: string, required?: boolean }[], showRemovedTags = true) {
constructor(funcName: string, docsIntro: string, extraArgs: { name: string, doc: string, defaultValue?: string, required?: boolean }[],
options?: {showRemovedTags? : true | boolean, cannotBeImportedMessage?: BaseUIElement}) {
this.funcName = funcName
this.showRemovedTags = showRemovedTags;
this.showRemovedTags = options?.showRemovedTags ?? true;
this.cannotBeImportedMessage = options?.cannotBeImportedMessage
this.docs = `${docsIntro}
Note that the contributor must zoom to at least zoomlevel 18 to be able to use this functionality.
@ -200,7 +202,7 @@ ${Utils.special_visualizations_importRequirementDocs}
pleaseLoginButton,
state
),
t.wrongType,
this.cannotBeImportedMessage ?? t.wrongType,
new UIEventSource(this.canBeImported(feature)))
}
@ -304,7 +306,10 @@ export class ConflateButton extends AbstractImportButton {
[{
name: "way_to_conflate",
doc: "The key, of which the corresponding value is the id of the OSM-way that must be conflated; typically a calculatedTag"
}]
}],
{
cannotBeImportedMessage: Translations.t.general.add.import.wrongTypeToConflate
}
);
}
@ -393,7 +398,7 @@ export class ImportWayButton extends AbstractImportButton implements AutoAction
doc: "Distance to distort the geometry to snap to this layer",
defaultValue: "0.1"
}],
false
{ showRemovedTags: false}
)
}
@ -548,7 +553,7 @@ export class ImportPointButton extends AbstractImportButton {
{name:"location_picker",
defaultValue: "photo",
doc: "Chooses the background for the precise location picker, options are 'map', 'photo' or 'osmbasedmap' or 'none' if the precise input picker should be disabled"}],
false
{ showRemovedTags: false}
)
}

View file

@ -6,6 +6,7 @@ import Translations from "./i18n/Translations";
import {QueryParameters} from "../Logic/Web/QueryParameters";
import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
import {DefaultGuiState} from "./DefaultGuiState";
export default class QueryParameterDocumentation {
@ -26,12 +27,12 @@ export default class QueryParameterDocumentation {
"Finally, the URL-hash is the part after the `#`. It is `node/1234` in this case."
])
public static UrlParamDocs(): object{
public static UrlParamDocs(): Map<string, string> {
const dummyLayout = new LayoutConfig({
id: "&gt;theme&lt;",
maintainer: "pietervdvn",
version: "0",
title: {en:"<theme>"},
title: {en: "<theme>"},
description: "A theme to generate docs with",
socialImage: "./assets/SocialImage.png",
startLat: 0,
@ -50,24 +51,26 @@ export default class QueryParameterDocumentation {
]
})
new DefaultGuiState(); // Init a featureSwitchState to init all the parameters
new FeatureSwitchState(dummyLayout)
QueryParameters.GetQueryParameter("layer-&lt;layer-id&gt;", "true", "Wether or not the layer with id <layer-id> is shown")
return QueryParameters.documentation
}
public static GenerateQueryParameterDocs(): BaseUIElement {
const docs: (string | BaseUIElement)[] = [...QueryParameterDocumentation.QueryParamDocsIntro];
for (const key in QueryParameters.documentation) {
this.UrlParamDocs().forEach((value, key) => {
const c = new Combine([
new Title(key, 2),
QueryParameters.documentation[key],
value,
QueryParameters.defaults[key] === undefined ? "No default value set" : `The default value is _${QueryParameters.defaults[key]}_`
])
docs.push(c)
}
})
return new Combine(docs).SetClass("flex flex-col")
}
}

View file

@ -35,7 +35,7 @@ import {ConflateButton, ImportPointButton, ImportWayButton} from "./Popup/Import
import TagApplyButton from "./Popup/TagApplyButton";
import AutoApplyButton from "./Popup/AutoApplyButton";
import * as left_right_style_json from "../assets/layers/left_right_style/left_right_style.json";
import {OpenIdEditor} from "./BigComponents/CopyrightPanel";
import {OpenIdEditor, OpenJosm} from "./BigComponents/CopyrightPanel";
import Toggle from "./Input/Toggle";
import Img from "./Base/Img";
import NoteCommentElement from "./Popup/NoteCommentElement";
@ -206,11 +206,13 @@ class NearbyImageVis implements SpecialVisualization {
const nearby = new Lazy(() => {
const towardsCenter = new CheckBox(t.onlyTowards, false)
const radiusValue= state?.osmConnection?.GetPreference("nearby-images-radius","300").sync(s => Number(s), [], i => ""+i) ?? new UIEventSource(300);
const radius = new Slider(25, 500, {value:
radiusValue, step: 25})
const radiusValue = state?.osmConnection?.GetPreference("nearby-images-radius","300").sync(s => Number(s), [], i => ""+i) ?? new UIEventSource(300);
const radius = new Slider(25, 500, {
value:
radiusValue, step: 25
})
const alreadyInTheImage = AllImageProviders.LoadImagesFor(tagSource)
const options: NearbyImageOptions & { value } = {
lon, lat,
@ -283,29 +285,31 @@ export default class SpecialVisualizations {
public static specialVisualizations: SpecialVisualization[] = SpecialVisualizations.init()
public static DocumentationFor(viz: SpecialVisualization): BaseUIElement {
return new Combine(
[
new Title(viz.funcName, 3),
viz.docs,
viz.args.length > 0 ? new Table(["name", "default", "description"],
viz.args.map(arg => {
let defaultArg = arg.defaultValue ?? "_undefined_"
if (defaultArg == "") {
defaultArg = "_empty string_"
}
return [arg.name, defaultArg, arg.doc];
})
) : undefined,
new Title("Example usage of " + viz.funcName, 4),
new FixedUiElement(
viz.example ?? "`{" + viz.funcName + "(" + viz.args.map(arg => arg.defaultValue).join(",") + ")}`"
).SetClass("literal-code"),
])
}
public static HelpMessage() {
const helpTexts =
SpecialVisualizations.specialVisualizations.map(viz => new Combine(
[
new Title(viz.funcName, 3),
viz.docs,
viz.args.length > 0 ? new Table(["name", "default", "description"],
viz.args.map(arg => {
let defaultArg = arg.defaultValue ?? "_undefined_"
if (defaultArg == "") {
defaultArg = "_empty string_"
}
return [arg.name, defaultArg, arg.doc];
})
) : undefined,
new Title("Example usage of " + viz.funcName, 4),
new FixedUiElement(
viz.example ?? "`{" + viz.funcName + "(" + viz.args.map(arg => arg.defaultValue).join(",") + ")}`"
).SetClass("literal-code"),
]
));
const helpTexts = SpecialVisualizations.specialVisualizations.map(viz => SpecialVisualizations.DocumentationFor(viz));
return new Combine([
new Combine([
@ -886,7 +890,14 @@ export default class SpecialVisualizations {
return new OpenIdEditor(state, undefined, feature.data.id)
}
},
{
funcName: "open_in_josm",
docs: "Opens the current view in the JOSM-editor",
args: [],
constr: (state, feature) => {
return new OpenJosm(state)
}
},
{
funcName: "clear_location_history",