2022-01-21 01:57:16 +01:00
import Combine from "../Base/Combine" ;
import { FlowStep } from "./FlowStep" ;
import { UIEventSource } from "../../Logic/UIEventSource" ;
import Link from "../Base/Link" ;
import { FixedUiElement } from "../Base/FixedUiElement" ;
import CheckBoxes from "../Input/Checkboxes" ;
import Title from "../Base/Title" ;
2022-03-17 11:01:52 +01:00
import { SubtleButton } from "../Base/SubtleButton" ;
import Svg from "../../Svg" ;
import { Utils } from "../../Utils" ;
import LayerConfig from "../../Models/ThemeConfig/LayerConfig" ;
2022-01-21 01:57:16 +01:00
2022-03-17 11:01:52 +01:00
export class ConfirmProcess extends Combine implements FlowStep < { features : any [ ] , layer : LayerConfig } > {
2022-01-21 01:57:16 +01:00
public IsValid : UIEventSource < boolean >
2022-03-17 11:01:52 +01:00
public Value : UIEventSource < { features : any [ ] , layer : LayerConfig } >
2022-01-21 01:57:16 +01:00
2022-03-17 11:01:52 +01:00
constructor ( v : { features : any [ ] , layer : LayerConfig } ) {
2022-01-21 01:57:16 +01:00
const toConfirm = [
new Combine ( [ "I have read the " , new Link ( "import guidelines on the OSM wiki" , "https://wiki.openstreetmap.org/wiki/Import_guidelines" , true ) ] ) ,
new FixedUiElement ( "I did contact the (local) community about this import" ) ,
new FixedUiElement ( "The license of the data to import allows it to be imported into OSM. They are allowed to be redistributed commercially, with only minimal attribution" ) ,
new FixedUiElement ( "The process is documented on the OSM-wiki (you'll need this link later)" )
] ;
const licenseClear = new CheckBoxes ( toConfirm )
super ( [
new Title ( "Did you go through the import process?" ) ,
2022-03-17 11:01:52 +01:00
licenseClear ,
new FixedUiElement ( "Alternatively, you can download the dataset to import directly" ) ,
new SubtleButton ( Svg . download_svg ( ) , "Download geojson" ) . OnClickWithLoading ( "Preparing your download" ,
async ( ) = > {
const geojson = {
type : "FeatureCollection" ,
features : v.features
}
Utils . offerContentsAsDownloadableFile ( JSON . stringify ( geojson ) , "prepared_import_" + v . layer . id + ".geojson" , {
mimetype : "application/vnd.geo+json"
} )
} )
2022-01-21 01:57:16 +01:00
] ) ;
this . SetClass ( "link-underline" )
this . IsValid = licenseClear . GetValue ( ) . map ( selected = > toConfirm . length == selected . length )
2022-03-17 11:01:52 +01:00
this . Value = new UIEventSource < { features : any [ ] , layer : LayerConfig } > ( v )
2022-01-21 01:57:16 +01:00
}
}