Feature: add download button in case of a bad custom theme

This commit is contained in:
Pieter Vander Vennet 2023-07-08 02:53:45 +02:00
parent 75b1a467e0
commit 8e50dd01c1
2 changed files with 44 additions and 9 deletions

View file

@ -1,9 +1,12 @@
import { Utils } from "./Utils"
import DetermineLayout from "./Logic/DetermineLayout"
import ThemeViewState from "./Models/ThemeViewState"
import SvelteUIElement from "./UI/Base/SvelteUIElement"
import ThemeViewGUI from "./UI/ThemeViewGUI.svelte"
import { FixedUiElement } from "./UI/Base/FixedUiElement"
import Combine from "./UI/Base/Combine"
import { SubtleButton } from "./UI/Base/SubtleButton"
import Svg from "./Svg"
import { Utils } from "./Utils"
// @ts-ignore
try {
@ -15,7 +18,17 @@ try {
})
.catch((err) => {
console.error("Error while initializing: ", err, err.stack)
new FixedUiElement(err).SetClass("block alert").AttachTo("maindiv")
new Combine([
new FixedUiElement(err).SetClass("block alert"),
new SubtleButton(Svg.download_svg(), "Download the raw file").onClick(() =>
Utils.offerContentsAsDownloadableFile(
DetermineLayout.getCustomDefinition(),
"mapcomplete-theme.json",
{ mimetype: "application/json" }
)
),
]).AttachTo("maindiv")
})
} catch (err) {
new FixedUiElement(err).SetClass("block alert").AttachTo("maindiv")