diff --git a/src/UI/Studio/EditLayer.svelte b/src/UI/Studio/EditLayer.svelte index 8faf4bac02..f90358d334 100644 --- a/src/UI/Studio/EditLayer.svelte +++ b/src/UI/Studio/EditLayer.svelte @@ -9,7 +9,7 @@ import { Utils } from "../../Utils" import type { ConversionMessage } from "../../Models/ThemeConfig/Conversion/Conversion" import ErrorIndicatorForRegion from "./ErrorIndicatorForRegion.svelte" - import { ChevronRightIcon } from "@rgossiaux/svelte-heroicons/solid" + import { ChevronRightIcon, TrashIcon } from "@rgossiaux/svelte-heroicons/solid" import SchemaBasedInput from "./SchemaBasedInput.svelte" import FloatOver from "../Base/FloatOver.svelte" import TagRenderingInput from "./TagRenderingInput.svelte" @@ -21,6 +21,7 @@ const layerSchema: ConfigMeta[] = layerSchemaRaw export let state: EditLayerState + export let backToStudio: () => void let messages = state.messages let hasErrors = messages.mapD( (m: ConversionMessage[]) => m.filter((m) => m.level === "error").length @@ -72,6 +73,10 @@ }) let highlightedItem: UIEventSource = state.highlightedItem + function deleteLayer() { + state.delete() + backToStudio() + }
@@ -113,6 +118,12 @@
+
+ + +
diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts index bf5bd09e18..2f80830ec9 100644 --- a/src/UI/Studio/EditLayerState.ts +++ b/src/UI/Studio/EditLayerState.ts @@ -107,6 +107,9 @@ export abstract class EditJsonState { return entry } + public async delete(){ + await this.server.delete(this.getId().data, this.category) + } public getStoreFor(path: ReadonlyArray): UIEventSource { const key = path.join(".") diff --git a/src/UI/Studio/StudioServer.ts b/src/UI/Studio/StudioServer.ts index 0151376a5f..bda3ac12c0 100644 --- a/src/UI/Studio/StudioServer.ts +++ b/src/UI/Studio/StudioServer.ts @@ -58,7 +58,14 @@ export default class StudioServer { return undefined } } - + async delete(id: string, category: "layers" | "themes") { + if (id === undefined || id === "") { + return + } + await fetch(this.urlFor(id, category), { + method: "DELETE" + }) + } async update(id: string, config: string, category: "layers" | "themes") { if (id === undefined || id === "") { return diff --git a/src/UI/StudioGUI.svelte b/src/UI/StudioGUI.svelte index fb1b647538..a53512db19 100644 --- a/src/UI/StudioGUI.svelte +++ b/src/UI/StudioGUI.svelte @@ -260,7 +260,7 @@
{:else if state === "editing_layer"} - + {state = undefined}}> {/if} - - -{#if { intro, tagrenderings: intro_tagrenderings }[$showIntro]?.sections} - { + {#if { intro, tagrenderings: intro_tagrenderings }[$showIntro]?.sections} + { showIntro.setData("no") }} - > -
- { + > +
+ { showIntro.setData("no") }} - /> -
- -{/if} + /> +
+
+ {/if} + + +