Refactoring: move 'snapToLayer' from 'preciseInput' into the preset, remove 'preferredBackground'. The addNewPointFlow _always_ shows the precise input flow with the basic map; so the preferredBackground became irrelevant

This commit is contained in:
Pieter Vander Vennet 2023-06-20 01:52:15 +02:00
parent ecf5c3cbe5
commit a6f7b1300a
127 changed files with 209 additions and 345 deletions

View file

@ -234,37 +234,27 @@ export default class LayerConfig extends WithContextLoader {
snapToLayers: undefined,
maxSnapDistance: undefined,
}
if (pr.preciseInput !== undefined) {
if (pr.preciseInput === true) {
pr.preciseInput = {
preferredBackground: undefined,
}
}
if (pr["preciseInput"] !== undefined) {
throw "Layer " + this.id + " still uses the old 'preciseInput'-field"
}
if (pr.snapToLayer !== undefined) {
let snapToLayers: string[]
if (typeof pr.preciseInput.snapToLayer === "string") {
snapToLayers = [pr.preciseInput.snapToLayer]
if (typeof pr.snapToLayer === "string") {
snapToLayers = [pr.snapToLayer]
} else {
snapToLayers = pr.preciseInput.snapToLayer
snapToLayers = pr.snapToLayer
}
let preferredBackground: (
| "map"
| "photo"
| "osmbasedmap"
| "historicphoto"
| string
)[]
if (typeof pr.preciseInput.preferredBackground === "string") {
preferredBackground = [pr.preciseInput.preferredBackground]
} else {
preferredBackground = pr.preciseInput.preferredBackground
}
preciseInput = {
preferredBackground,
snapToLayers,
maxSnapDistance: pr.preciseInput.maxSnapDistance ?? 10,
maxSnapDistance: pr.maxSnapDistance ?? 10,
}
} else if (pr.maxSnapDistance !== undefined) {
throw (
"Layer " +
this.id +
" defines a maxSnapDistance, but does not include a `snapToLayer`"
)
}
const config: PresetConfig = {