Further translations of the import helper

This commit is contained in:
Pieter Vander Vennet 2022-04-14 19:46:14 +02:00
parent 8e2e227563
commit 0d81decdc7
6 changed files with 105 additions and 22 deletions

View file

@ -7,7 +7,6 @@ import {UIEventSource} from "../../Logic/UIEventSource";
import Constants from "../../Models/Constants";
import RelationsTracker from "../../Logic/Osm/RelationsTracker";
import {VariableUiElement} from "../Base/VariableUIElement";
import {FixedUiElement} from "../Base/FixedUiElement";
import {FlowStep} from "./FlowStep";
import Loading from "../Base/Loading";
import {SubtleButton} from "../Base/SubtleButton";
@ -28,6 +27,7 @@ import * as import_candidate from "../../assets/layers/import_candidate/import_c
import {GeoOperations} from "../../Logic/GeoOperations";
import FeatureInfoBox from "../Popup/FeatureInfoBox";
import {ImportUtils} from "./ImportUtils";
import Translations from "../i18n/Translations";
/**
* Given the data to import, the bbox and the layer, will query overpass for similar items
@ -190,6 +190,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
features: toImportWithNearby
})
const t = Translations.t.importHelper.conflationChecker
const conflationMaps = new Combine([
new VariableUiElement(
@ -197,7 +198,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
if (geojson === undefined) {
return undefined;
}
return new SubtleButton(Svg.download_svg(), "Download the loaded geojson from overpass").onClick(() => {
return new SubtleButton(Svg.download_svg(), t.downloadOverpassData).onClick(() => {
Utils.offerContentsAsDownloadableFile(JSON.stringify(geojson, null, " "), "mapcomplete-" + layer.id + ".geojson", {
mimetype: "application/json+geo"
})
@ -208,43 +209,53 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
return undefined;
}
if (age < 0) {
return new FixedUiElement("Cache was expired")
return t.cacheExpired
}
return new FixedUiElement("Loaded data is from the cache and is " + Utils.toHumanTime(age) + " old")
return t.loadedDataAge.Subs({age: Utils.toHumanTime(age)})
})),
new Title("Live data on OSM"),
"The "+toImport.features.length+" red elements on the following map are all your import candidates.",
new VariableUiElement(geojson.map(geojson => new FixedUiElement((geojson?.features?.length ?? "No") + " elements are loaded from OpenStreetMap which match the layer "+layer.id+". Zooming in might be needed to show them"))),
new Title(t.titleLive),
t.importCandidatesCount.Subs({count:toImport.features.length }),
new VariableUiElement(geojson.map(geojson => {
if(geojson?.features?.length === undefined && geojson?.features?.length === 0){
return t.nothingLoaded.Subs(layer).SetClass("alert")
}
return new Combine([
t.osmLoaded.Subs({count: geojson.features.length, name: layer.name}),
])
})),
osmLiveData,
new Combine(["The live data is shown if the zoomlevel is at least ", zoomLevel, ". The current zoom level is ", new VariableUiElement(osmLiveData.location.map(l => "" + l.zoom))]).SetClass("flex"),
new Title("Nearby features"),
new Combine(["The following map shows features to import which have an OSM-feature within ", nearbyCutoff, "meter"]).SetClass("flex"),
new VariableUiElement(osmLiveData.location.map(location => {
return t.zoomIn.Subs({needed:zoomLevel, current: location.zoom })
} )),
new Title(t.titleNearby),
new Combine([t.mapShowingNearbyIntro, nearbyCutoff]).SetClass("flex"),
new VariableUiElement(toImportWithNearby.features.map(feats =>
new FixedUiElement("The "+ feats.length +" red elements on the following map will <b>not</b> be imported!").SetClass("alert"))),
"Set the range to 0 or 1 if you want to import them all",
t.nearbyWarn.Subs({count: feats.length}).SetClass("alert"))),
,t.setRangeToZero,
matchedFeaturesMap]).SetClass("flex flex-col")
super([
new Title("Comparison with existing data"),
new Title(t.title),
new VariableUiElement(overpassStatus.map(d => {
if (d === "idle") {
return new Loading("Checking local storage...")
}
if (d["error"] !== undefined) {
return new FixedUiElement("Could not load latest data from overpass: " + d["error"]).SetClass("alert")
return new Loading(t.states.idle)
}
if (d === "running") {
return new Loading("Querying overpass...")
return new Loading(t.states.running)
}
if (d["error"] !== undefined) {
return t.states.error.Subs(d).SetClass("alert")
}
if (d === "cached") {
return conflationMaps
}
if (d === "success") {
return conflationMaps
}
return new FixedUiElement("Unexpected state " + d).SetClass("alert")
return t.states.unexpected.Subs({state: d}).SetClass("alert")
}))
])

View file

@ -36,7 +36,7 @@ export default class ImportHelperGui extends LeftIndex {
.then(t.mapPreview, geojson => new MapPreview(state, geojson))
.then(t.selectTheme, v => new SelectTheme(v))
.then(t.compareToAlreadyExistingNotes, v => new CompareToAlreadyExistingNotes(state, v))
.then("Compare with existing data", v => new ConflationChecker(state, v))
.then(t.conflationChecker, v => new ConflationChecker(state, v))
.then(t.confirmProcess, v => new ConfirmProcess(v))
.then(t.askMetadata, (v) => new AskMetadata(v))
.finish(t.createNotes.title, v => new CreateNotes(state, v));