diff --git a/UI/BigComponents/ExportDataButton.ts b/UI/BigComponents/DownloadPanel.ts similarity index 72% rename from UI/BigComponents/ExportDataButton.ts rename to UI/BigComponents/DownloadPanel.ts index 4e93503e87..0451d28fc4 100644 --- a/UI/BigComponents/ExportDataButton.ts +++ b/UI/BigComponents/DownloadPanel.ts @@ -10,41 +10,43 @@ import {GeoOperations} from "../../Logic/GeoOperations"; import Toggle from "../Input/Toggle"; import Title from "../Base/Title"; -export class ExportDataButton extends Toggle { +export class DownloadPanel extends Toggle { constructor() { const t = Translations.t.general.download - const somethingLoaded = State.state.featurePipeline.features.map(features => features.length > 0); + const somethingLoaded = State.state.featurePipeline.features.map(features => features.length > 0); const includeMetaToggle = new CheckBoxes([t.includeMetaData.Clone()]) const metaisIncluded = includeMetaToggle.GetValue().map(selected => selected.length > 0) - const buttonGeoJson = new SubtleButton(Svg.floppy_ui(), + const buttonGeoJson = new SubtleButton(Svg.floppy_ui(), new Combine([t.downloadGeojson.Clone().SetClass("font-bold"), - t.downloadGeoJsonHelper.Clone()]).SetClass("flex flex-col")) + t.downloadGeoJsonHelper.Clone()]).SetClass("flex flex-col")) .onClick(() => { const geojson = FeatureSourceUtils.extractGeoJson(State.state.featurePipeline, {metadata: metaisIncluded.data}) const name = State.state.layoutToUse.data.id; - Utils.offerContentsAsDownloadableFile(JSON.stringify(geojson), - `MapComplete_${name}_export_${new Date().toISOString().substr(0,19)}.geojson`); + Utils.offerContentsAsDownloadableFile(JSON.stringify(geojson), + `MapComplete_${name}_export_${new Date().toISOString().substr(0, 19)}.geojson`, { + mimetype: "application/vnd.geo+json" + }); }) - - const buttonCSV = new SubtleButton(Svg.floppy_ui(), new Combine( + + const buttonCSV = new SubtleButton(Svg.floppy_ui(), new Combine( [t.downloadCSV.Clone().SetClass("font-bold"), - t.downloadCSVHelper.Clone()]).SetClass("flex flex-col")) + t.downloadCSVHelper.Clone()]).SetClass("flex flex-col")) .onClick(() => { const geojson = FeatureSourceUtils.extractGeoJson(State.state.featurePipeline, {metadata: metaisIncluded.data}) const csv = GeoOperations.toCSV(geojson.features) Utils.offerContentsAsDownloadableFile(csv, - `MapComplete_${name}_export_${new Date().toISOString().substr(0,19)}.csv`,{ - mimetype:"text/csv" + `MapComplete_${name}_export_${new Date().toISOString().substr(0, 19)}.csv`, { + mimetype: "text/csv" }); }) const downloadButtons = new Combine( [new Title(t.title), buttonGeoJson, buttonCSV, includeMetaToggle, t.licenseInfo.Clone().SetClass("link-underline")]) - .SetClass("w-full flex flex-col border-4 border-gray-300 rounded-3xl p-4") - + .SetClass("w-full flex flex-col border-4 border-gray-300 rounded-3xl p-4") + super( downloadButtons, t.noDataLoaded.Clone(), diff --git a/UI/BigComponents/LayerControlPanel.ts b/UI/BigComponents/LayerControlPanel.ts index c8837fbccc..5008ac6357 100644 --- a/UI/BigComponents/LayerControlPanel.ts +++ b/UI/BigComponents/LayerControlPanel.ts @@ -7,7 +7,7 @@ import Translations from "../i18n/Translations"; import {UIEventSource} from "../../Logic/UIEventSource"; import BaseUIElement from "../BaseUIElement"; import Toggle from "../Input/Toggle"; -import {ExportDataButton} from "./ExportDataButton"; +import {DownloadPanel} from "./DownloadPanel"; export default class LayerControlPanel extends ScrollableFullScreen { @@ -37,7 +37,7 @@ export default class LayerControlPanel extends ScrollableFullScreen { )) elements.push(new Toggle( - new ExportDataButton(), + new DownloadPanel(), undefined, State.state.featureSwitchEnableExport ))