forked from MapComplete/MapComplete
Fixes to import flow
This commit is contained in:
parent
2c1144cf10
commit
bce8ae3e34
4 changed files with 32 additions and 16 deletions
|
@ -13,19 +13,20 @@ export class ConfirmProcess extends Combine implements FlowStep<{ features: any[
|
||||||
|
|
||||||
constructor(v: { features: any[], theme: string }) {
|
constructor(v: { features: any[], theme: string }) {
|
||||||
const t = Translations.t.importHelper.confirmProcess;
|
const t = Translations.t.importHelper.confirmProcess;
|
||||||
const toConfirm = [
|
const elements = [
|
||||||
new Link(t.readImportGuidelines, "https://wiki.openstreetmap.org/wiki/Import_guidelines", true),
|
new Link(t.readImportGuidelines, "https://wiki.openstreetmap.org/wiki/Import_guidelines", true),
|
||||||
t.contactedCommunity,
|
t.contactedCommunity,
|
||||||
t.licenseIsCompatible,
|
t.licenseIsCompatible,
|
||||||
t.wikipageIsMade
|
t.wikipageIsMade
|
||||||
];
|
]
|
||||||
|
const toConfirm = new CheckBoxes(elements);
|
||||||
|
|
||||||
super([
|
super([
|
||||||
new Title(t.titleLong),
|
new Title(t.titleLong),
|
||||||
new CheckBoxes(toConfirm),
|
toConfirm,
|
||||||
]);
|
]);
|
||||||
this.SetClass("link-underline")
|
this.SetClass("link-underline")
|
||||||
this.IsValid = new CheckBoxes(toConfirm).GetValue().map(selected => toConfirm.length == selected.length)
|
this.IsValid = toConfirm.GetValue().map(selected => elements.length == selected.length)
|
||||||
this.Value = new UIEventSource<{ features: any[], theme: string }>(v)
|
this.Value = new UIEventSource<{ features: any[], theme: string }>(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -217,7 +217,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
|
||||||
new Title(t.titleLive),
|
new Title(t.titleLive),
|
||||||
t.importCandidatesCount.Subs({count:toImport.features.length }),
|
t.importCandidatesCount.Subs({count:toImport.features.length }),
|
||||||
new VariableUiElement(geojson.map(geojson => {
|
new VariableUiElement(geojson.map(geojson => {
|
||||||
if(geojson?.features?.length === undefined && geojson?.features?.length === 0){
|
if(geojson?.features?.length === undefined || geojson?.features?.length === 0){
|
||||||
return t.nothingLoaded.Subs(layer).SetClass("alert")
|
return t.nothingLoaded.Subs(layer).SetClass("alert")
|
||||||
}
|
}
|
||||||
return new Combine([
|
return new Combine([
|
||||||
|
@ -233,7 +233,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
|
||||||
new Combine([t.mapShowingNearbyIntro, nearbyCutoff]).SetClass("flex"),
|
new Combine([t.mapShowingNearbyIntro, nearbyCutoff]).SetClass("flex"),
|
||||||
new VariableUiElement(toImportWithNearby.features.map(feats =>
|
new VariableUiElement(toImportWithNearby.features.map(feats =>
|
||||||
t.nearbyWarn.Subs({count: feats.length}).SetClass("alert"))),
|
t.nearbyWarn.Subs({count: feats.length}).SetClass("alert"))),
|
||||||
,t.setRangeToZero,
|
t.setRangeToZero,
|
||||||
matchedFeaturesMap]).SetClass("flex flex-col")
|
matchedFeaturesMap]).SetClass("flex flex-col")
|
||||||
|
|
||||||
super([
|
super([
|
||||||
|
@ -246,7 +246,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
|
||||||
return new Loading(t.states.running)
|
return new Loading(t.states.running)
|
||||||
}
|
}
|
||||||
if (d["error"] !== undefined) {
|
if (d["error"] !== undefined) {
|
||||||
return t.states.error.Subs(d).SetClass("alert")
|
return t.states.error.Subs({error: d["error"]}).SetClass("alert")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d === "cached") {
|
if (d === "cached") {
|
||||||
|
|
|
@ -9,12 +9,14 @@ import {FixedUiElement} from "../Base/FixedUiElement";
|
||||||
import {SubtleButton} from "../Base/SubtleButton";
|
import {SubtleButton} from "../Base/SubtleButton";
|
||||||
import Svg from "../../Svg";
|
import Svg from "../../Svg";
|
||||||
import Translations from "../i18n/Translations";
|
import Translations from "../i18n/Translations";
|
||||||
|
import {Translation} from "../i18n/Translation";
|
||||||
|
|
||||||
export class CreateNotes extends Combine {
|
export class CreateNotes extends Combine {
|
||||||
|
|
||||||
public static createNoteContents(feature: {properties: any, geometry: {coordinates: [number,number]}},
|
|
||||||
options: {wikilink: string; intro: string; source: string, theme: string }
|
public static createNoteContentsUi(feature: {properties: any, geometry: {coordinates: [number,number]}},
|
||||||
): string[]{
|
options: {wikilink: string; intro: string; source: string, theme: string }
|
||||||
|
): (Translation | string)[]{
|
||||||
const src = feature.properties["source"] ?? feature.properties["src"] ?? options.source
|
const src = feature.properties["source"] ?? feature.properties["src"] ?? options.source
|
||||||
delete feature.properties["source"]
|
delete feature.properties["source"]
|
||||||
delete feature.properties["src"]
|
delete feature.properties["src"]
|
||||||
|
@ -41,14 +43,26 @@ export class CreateNotes extends Combine {
|
||||||
return [
|
return [
|
||||||
options.intro,
|
options.intro,
|
||||||
extraNote,
|
extraNote,
|
||||||
note.datasource.Subs({source: src}).txt,
|
note.datasource.Subs({source: src}),
|
||||||
note.wikilink.Subs(options).txt,
|
note.wikilink.Subs(options),
|
||||||
'',
|
'',
|
||||||
note.importEasily.txt,
|
note.importEasily,
|
||||||
`https://mapcomplete.osm.be/${options.theme}.html?z=18&lat=${lat}&lon=${lon}#import`,
|
`https://mapcomplete.osm.be/${options.theme}.html?z=18&lat=${lat}&lon=${lon}#import`,
|
||||||
...tags]
|
...tags]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static createNoteContents(feature: {properties: any, geometry: {coordinates: [number,number]}},
|
||||||
|
options: {wikilink: string; intro: string; source: string, theme: string }
|
||||||
|
): string[]{
|
||||||
|
return CreateNotes.createNoteContentsUi(feature, options).map(trOrStr => {
|
||||||
|
if(typeof trOrStr === "string"){
|
||||||
|
return trOrStr
|
||||||
|
}
|
||||||
|
return trOrStr.txt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
constructor(state: { osmConnection: OsmConnection }, v: { features: any[]; wikilink: string; intro: string; source: string, theme: string }) {
|
constructor(state: { osmConnection: OsmConnection }, v: { features: any[]; wikilink: string; intro: string; source: string, theme: string }) {
|
||||||
const t = Translations.t.importHelper.createNotes;
|
const t = Translations.t.importHelper.createNotes;
|
||||||
const createdNotes: UIEventSource<number[]> = new UIEventSource<number[]>([])
|
const createdNotes: UIEventSource<number[]> = new UIEventSource<number[]>([])
|
||||||
|
@ -83,7 +97,7 @@ export class CreateNotes extends Combine {
|
||||||
)))),
|
)))),
|
||||||
new Combine([
|
new Combine([
|
||||||
Svg.party_svg().SetClass("w-24"),
|
Svg.party_svg().SetClass("w-24"),
|
||||||
t.done.Subs(v.features.length).SetClass("thanks"),
|
t.done.Subs({count: v.features.length}).SetClass("thanks"),
|
||||||
new SubtleButton(Svg.note_svg(),
|
new SubtleButton(Svg.note_svg(),
|
||||||
t.openImportViewer , {
|
t.openImportViewer , {
|
||||||
url: "import_viewer.html"
|
url: "import_viewer.html"
|
||||||
|
|
|
@ -4,13 +4,14 @@ import {UIEventSource} from "../../Logic/UIEventSource";
|
||||||
import Translations from "../i18n/Translations";
|
import Translations from "../i18n/Translations";
|
||||||
import Title from "../Base/Title";
|
import Title from "../Base/Title";
|
||||||
import {CreateNotes} from "./CreateNotes";
|
import {CreateNotes} from "./CreateNotes";
|
||||||
|
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||||
|
|
||||||
export default class Introdution extends Combine implements FlowStep<void> {
|
export default class Introdution extends Combine implements FlowStep<void> {
|
||||||
readonly IsValid: UIEventSource<boolean>;
|
readonly IsValid: UIEventSource<boolean>;
|
||||||
readonly Value: UIEventSource<void>;
|
readonly Value: UIEventSource<void>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const example = CreateNotes.createNoteContents({
|
const example = CreateNotes.createNoteContentsUi({
|
||||||
properties:{
|
properties:{
|
||||||
"some_key":"some_value",
|
"some_key":"some_value",
|
||||||
"note":"a note in the original dataset"
|
"note":"a note in the original dataset"
|
||||||
|
@ -23,7 +24,7 @@ export default class Introdution extends Combine implements FlowStep<void> {
|
||||||
intro: "There might be an XYZ here",
|
intro: "There might be an XYZ here",
|
||||||
theme: "theme",
|
theme: "theme",
|
||||||
source: "source of the data"
|
source: "source of the data"
|
||||||
})
|
}).map(el => el === "" ? new FixedUiElement("").SetClass("block") : el)
|
||||||
|
|
||||||
super([
|
super([
|
||||||
new Title(Translations.t.importHelper.introduction.title),
|
new Title(Translations.t.importHelper.introduction.title),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue