forked from MapComplete/MapComplete
Further stabilization of UK-addresses: add minzoom requirement to import button, fix eternal loading message
This commit is contained in:
parent
561b21d2fe
commit
d8fa054a34
8 changed files with 71 additions and 40 deletions
|
@ -9,11 +9,17 @@ import Constants from "../../Models/Constants";
|
|||
import Toggle from "../Input/Toggle";
|
||||
import CreateNewNodeAction from "../../Logic/Osm/Actions/CreateNewNodeAction";
|
||||
import {Tag} from "../../Logic/Tags/Tag";
|
||||
import Loading from "../Base/Loading";
|
||||
|
||||
export default class ImportButton extends Toggle {
|
||||
constructor(imageUrl: string | BaseUIElement, message: string | BaseUIElement,
|
||||
originalTags: UIEventSource<any>,
|
||||
newTags: UIEventSource<Tag[]>, lat: number, lon: number) {
|
||||
newTags: UIEventSource<Tag[]>,
|
||||
lat: number, lon: number,
|
||||
minZoom: number,
|
||||
state: {
|
||||
locationControl: UIEventSource<{ zoom: number }>
|
||||
}) {
|
||||
const t = Translations.t.general.add;
|
||||
const isImported = originalTags.map(tags => tags._imported === "yes")
|
||||
const appliedTags = new Toggle(
|
||||
|
@ -30,6 +36,7 @@ export default class ImportButton extends Toggle {
|
|||
)
|
||||
const button = new SubtleButton(imageUrl, message)
|
||||
|
||||
minZoom = Math.max(16, minZoom ?? 19)
|
||||
|
||||
button.onClick(async () => {
|
||||
if (isImported.data) {
|
||||
|
@ -49,11 +56,13 @@ export default class ImportButton extends Toggle {
|
|||
|
||||
})
|
||||
|
||||
const withLoadingCheck = new Toggle(
|
||||
t.stillLoading,
|
||||
const withLoadingCheck = new Toggle(new Toggle(
|
||||
new Loading(t.stillLoading.Clone()),
|
||||
new Combine([button, appliedTags]).SetClass("flex flex-col"),
|
||||
State.state.featurePipeline.runningQuery
|
||||
)
|
||||
),t.zoomInFurther.Clone(),
|
||||
state.locationControl.map(l => l.zoom >= minZoom)
|
||||
)
|
||||
const importButton = new Toggle(t.hasBeenImported, withLoadingCheck, isImported)
|
||||
|
||||
const pleaseLoginButton =
|
||||
|
|
|
@ -396,7 +396,10 @@ export default class SpecialVisualizations {
|
|||
name: "icon",
|
||||
doc: "A nice icon to show in the button",
|
||||
defaultValue: "./assets/svg/addSmall.svg"
|
||||
}],
|
||||
},
|
||||
{name:"minzoom",
|
||||
doc: "How far the contributor must zoom in before being able to import the point",
|
||||
defaultValue: "18"}],
|
||||
docs: `This button will copy the data from an external dataset into OpenStreetMap. It is only functional in official themes but can be tested in unofficial themes.
|
||||
|
||||
If you want to import a dataset, make sure that:
|
||||
|
@ -439,13 +442,13 @@ There are also some technicalities in your theme to keep in mind:
|
|||
return newTags
|
||||
})
|
||||
const id = tagSource.data.id;
|
||||
const feature = State.state.allElements.ContainingFeatures.get(id)
|
||||
const feature = state.allElements.ContainingFeatures.get(id)
|
||||
if (feature.geometry.type !== "Point") {
|
||||
return new FixedUiElement("Error: can only import point objects").SetClass("alert")
|
||||
}
|
||||
const [lon, lat] = feature.geometry.coordinates;
|
||||
return new ImportButton(
|
||||
args[2], args[1], tagSource, rewrittenTags, lat, lon
|
||||
args[2], args[1], tagSource, rewrittenTags, lat, lon, Number(args[3]), state
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue