forked from MapComplete/MapComplete
Further translations of the import helper
This commit is contained in:
parent
8e2e227563
commit
0d81decdc7
6 changed files with 105 additions and 22 deletions
|
@ -39,6 +39,39 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
|
|||
* }
|
||||
* rewritten // => expected
|
||||
*
|
||||
* // should use the ID if one is present instead of the index
|
||||
* const theme = {
|
||||
* layers: [
|
||||
* {
|
||||
* tagRenderings:[
|
||||
*
|
||||
* {id: "some-tr",
|
||||
* question:{
|
||||
* en:"Question?"
|
||||
* }
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* const rewritten = new AddContextToTranslations<any>("prefix:").convert(theme, "context").result
|
||||
* const expected = {
|
||||
* layers: [
|
||||
* {
|
||||
* tagRenderings:[
|
||||
*
|
||||
* {id: "some-tr",
|
||||
* question:{
|
||||
* _context: "prefix:context.layers.0.tagRenderings.some-tr.question"
|
||||
* en:"Question?"
|
||||
* }
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* rewritten // => expected
|
||||
*
|
||||
* // should preserve nulls
|
||||
* const theme = {
|
||||
* layers: [
|
||||
|
@ -70,6 +103,17 @@ export class AddContextToTranslations<T> extends DesugaringStep<T> {
|
|||
return leaf
|
||||
}
|
||||
if (typeof leaf === "object") {
|
||||
|
||||
// follow the path. If we encounter a number, check that there is no ID we can use instead
|
||||
let breadcrumb = json;
|
||||
for (let i = 0; i < path.length; i++) {
|
||||
const pointer = path[i]
|
||||
breadcrumb = breadcrumb[pointer]
|
||||
if(pointer.match("[0-9]+") && breadcrumb["id"] !== undefined){
|
||||
path[i] = breadcrumb["id"]
|
||||
}
|
||||
}
|
||||
|
||||
return {...leaf, _context: this._prefix + context + "." + path.join(".")}
|
||||
} else {
|
||||
return leaf
|
||||
|
|
|
@ -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")
|
||||
}))
|
||||
|
||||
])
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -9,7 +9,8 @@ export default class InputElementWrapper<T> extends InputElement<T> {
|
|||
private readonly _inputElement: InputElement<T>;
|
||||
private readonly _renderElement: BaseUIElement
|
||||
|
||||
constructor(inputElement: InputElement<T>, translation: Translation, key: string, tags: UIEventSource<any>, state: FeaturePipelineState) {
|
||||
constructor(inputElement: InputElement<T>, translation: Translation, key: string,
|
||||
tags: UIEventSource<any>, state: FeaturePipelineState) {
|
||||
super()
|
||||
this._inputElement = inputElement;
|
||||
const mapping = new Map<string, BaseUIElement>()
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
[
|
||||
{
|
||||
"start_date": "2022-05-30",
|
||||
"end_date":"2022-06-05",
|
||||
"message": "The 3rd of June is <b><a href='https://en.wikipedia.org/wiki/World_Bicycle_Day'>World Bicycle Day</a></b>. Go find a bike shop or bike pump nearby",
|
||||
"featured_theme": "cyclofix"
|
||||
},
|
||||
{
|
||||
"start_date": "2022-04-18",
|
||||
"end_date": "2022-04-24",
|
||||
|
|
|
@ -310,6 +310,27 @@
|
|||
"titleLong": "Did you go through the import process?",
|
||||
"wikipageIsMade": "The process is documented on the OSM-wiki (you'll need this link later)"
|
||||
},
|
||||
"conflationChecker": {
|
||||
"cacheExpired": "Cache was expired",
|
||||
"downloadOverpassData": "Download the loaded geojson from overpass",
|
||||
"importCandidatesCount": "The {count} red elements on the following map are all your import candidates.",
|
||||
"loadedDataAge": "Loaded data is from the cache and is {age} old",
|
||||
"mapShowingNearbyIntro": "The following map shows features to import which have an OSM-feature within ",
|
||||
"nearbyWarn": "The {count} red elements on the following map will <b>not</b> be imported!",
|
||||
"nothingLoaded": "No elements are loaded from OpenStreetMap which match the current layer {name}",
|
||||
"osmLoaded": "{count} elements are loaded from OpenStreetMap which match the layer <b>{name}</b>.",
|
||||
"setRangeToZero": "Set the range to 0 or 1 if you want to import them all",
|
||||
"states": {
|
||||
"error": "Could not load latest data from overpass due to {error}",
|
||||
"idle": "Checking local storage...",
|
||||
"running": "Querying overpass...",
|
||||
"unexpected": "Unexpected state {state}"
|
||||
},
|
||||
"title": "Compare with existing data",
|
||||
"titleLive": "Live data on OSM",
|
||||
"titleNearby": "Nearby features",
|
||||
"zoomIn": "The live data is shown if the zoomlevel is at least {needed}. The current zoom level is {current}"
|
||||
},
|
||||
"createNotes": {
|
||||
"creating": "Created <b>{count}</b> notes out of {total}",
|
||||
"done": "All {count} notes have been created!",
|
||||
|
|
Loading…
Reference in a new issue