Fixes to import flow

This commit is contained in:
pietervdvn 2022-04-19 23:42:58 +02:00
parent 2c1144cf10
commit bce8ae3e34
4 changed files with 32 additions and 16 deletions

View file

@ -13,19 +13,20 @@ export class ConfirmProcess extends Combine implements FlowStep<{ features: any[
constructor(v: { features: any[], theme: string }) {
const t = Translations.t.importHelper.confirmProcess;
const toConfirm = [
const elements = [
new Link(t.readImportGuidelines, "https://wiki.openstreetmap.org/wiki/Import_guidelines", true),
t.contactedCommunity,
t.licenseIsCompatible,
t.wikipageIsMade
];
]
const toConfirm = new CheckBoxes(elements);
super([
new Title(t.titleLong),
new CheckBoxes(toConfirm),
toConfirm,
]);
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)
}
}

View file

@ -217,7 +217,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
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){
if(geojson?.features?.length === undefined || geojson?.features?.length === 0){
return t.nothingLoaded.Subs(layer).SetClass("alert")
}
return new Combine([
@ -233,7 +233,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
new Combine([t.mapShowingNearbyIntro, nearbyCutoff]).SetClass("flex"),
new VariableUiElement(toImportWithNearby.features.map(feats =>
t.nearbyWarn.Subs({count: feats.length}).SetClass("alert"))),
,t.setRangeToZero,
t.setRangeToZero,
matchedFeaturesMap]).SetClass("flex flex-col")
super([
@ -246,7 +246,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea
return new Loading(t.states.running)
}
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") {

View file

@ -9,12 +9,14 @@ import {FixedUiElement} from "../Base/FixedUiElement";
import {SubtleButton} from "../Base/SubtleButton";
import Svg from "../../Svg";
import Translations from "../i18n/Translations";
import {Translation} from "../i18n/Translation";
export class CreateNotes extends Combine {
public static createNoteContents(feature: {properties: any, geometry: {coordinates: [number,number]}},
options: {wikilink: string; intro: string; source: string, theme: string }
): string[]{
public static createNoteContentsUi(feature: {properties: any, geometry: {coordinates: [number,number]}},
options: {wikilink: string; intro: string; source: string, theme: string }
): (Translation | string)[]{
const src = feature.properties["source"] ?? feature.properties["src"] ?? options.source
delete feature.properties["source"]
delete feature.properties["src"]
@ -41,14 +43,26 @@ export class CreateNotes extends Combine {
return [
options.intro,
extraNote,
note.datasource.Subs({source: src}).txt,
note.wikilink.Subs(options).txt,
note.datasource.Subs({source: src}),
note.wikilink.Subs(options),
'',
note.importEasily.txt,
note.importEasily,
`https://mapcomplete.osm.be/${options.theme}.html?z=18&lat=${lat}&lon=${lon}#import`,
...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 }) {
const t = Translations.t.importHelper.createNotes;
const createdNotes: UIEventSource<number[]> = new UIEventSource<number[]>([])
@ -83,7 +97,7 @@ export class CreateNotes extends Combine {
)))),
new Combine([
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(),
t.openImportViewer , {
url: "import_viewer.html"

View file

@ -4,13 +4,14 @@ import {UIEventSource} from "../../Logic/UIEventSource";
import Translations from "../i18n/Translations";
import Title from "../Base/Title";
import {CreateNotes} from "./CreateNotes";
import {FixedUiElement} from "../Base/FixedUiElement";
export default class Introdution extends Combine implements FlowStep<void> {
readonly IsValid: UIEventSource<boolean>;
readonly Value: UIEventSource<void>;
constructor() {
const example = CreateNotes.createNoteContents({
const example = CreateNotes.createNoteContentsUi({
properties:{
"some_key":"some_value",
"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",
theme: "theme",
source: "source of the data"
})
}).map(el => el === "" ? new FixedUiElement("").SetClass("block") : el)
super([
new Title(Translations.t.importHelper.introduction.title),