diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts index 228803436..d52ebf765 100644 --- a/src/UI/Studio/EditLayerState.ts +++ b/src/UI/Studio/EditLayerState.ts @@ -5,7 +5,7 @@ import { Conversion, ConversionMessage, DesugaringContext, - Pipe, + Pipe } from "../../Models/ThemeConfig/Conversion/Conversion" import { PrepareLayer } from "../../Models/ThemeConfig/Conversion/PrepareLayer" import { PrevalidateTheme, ValidateLayer } from "../../Models/ThemeConfig/Conversion/Validation" @@ -97,16 +97,19 @@ export abstract class EditJsonState { public startSavingUpdates(enabled = true) { this.sendingUpdates = enabled - this.register( - ["credits"], - this.osmConnection.userDetails.mapD((u) => u.name), - false - ) - this.register( - ["credits:uid"], - this.osmConnection.userDetails.mapD((u) => u.uid), - false - ) + if (!this.server.isDirect) { + + this.register( + ["credits"], + this.osmConnection.userDetails.mapD((u) => u.name), + false + ) + this.register( + ["credits:uid"], + this.osmConnection.userDetails.mapD((u) => u.uid), + false + ) + } if (enabled) { this.configuration.ping() } @@ -159,7 +162,7 @@ export abstract class EditJsonState { } public getSchemaStartingWith(path: string[]) { - if(path === undefined){ + if (path === undefined) { return undefined } return this.schema.filter( @@ -174,10 +177,10 @@ export abstract class EditJsonState { path, type: "translation", hints: { - typehint: "translation", + typehint: "translation" }, required: origConfig.required ?? false, - description: origConfig.description ?? "A translatable object", + description: origConfig.description ?? "A translatable object" } } @@ -329,7 +332,7 @@ export default class EditLayerState extends EditJsonState { public readonly imageUploadManager = { getCountsFor() { return 0 - }, + } } public readonly layout: { getMatchingLayer: (key: any) => LayerConfig } public readonly featureSwitches: { @@ -345,8 +348,8 @@ export default class EditLayerState extends EditJsonState { properties: this.testTags.data, geometry: { type: "Point", - coordinates: [3.21, 51.2], - }, + coordinates: [3.21, 51.2] + } } constructor( @@ -363,10 +366,10 @@ export default class EditLayerState extends EditJsonState { } catch (e) { return undefined } - }, + } } this.featureSwitches = { - featureSwitchIsDebugging: new UIEventSource(true), + featureSwitchIsDebugging: new UIEventSource(true) } this.addMissingTagRenderingIds() @@ -455,7 +458,7 @@ export default class EditLayerState extends EditJsonState { } const state: DesugaringContext = { tagRenderings: sharedQuestions, - sharedLayers: layers, + sharedLayers: layers } const prepare = this.buildValidation(state) const context = ConversionContext.construct([], ["prepare"]) @@ -531,7 +534,7 @@ export class EditThemeState extends EditJsonState { } const state: DesugaringContext = { tagRenderings: sharedQuestions, - sharedLayers: layers, + sharedLayers: layers } const prepare = this.buildValidation(state) const context = ConversionContext.construct([], ["prepare"]) diff --git a/src/UI/Studio/StudioServer.ts b/src/UI/Studio/StudioServer.ts index 6df83f48c..216c22b18 100644 --- a/src/UI/Studio/StudioServer.ts +++ b/src/UI/Studio/StudioServer.ts @@ -18,8 +18,9 @@ export default class StudioServer { | { error: any } | undefined > + public isDirect: boolean - constructor(url: string, userId: Store) { + constructor(url: string, userId: Store, isDirect: boolean) { this.url = url this._userId = userId this.overview = UIEventSource.FromPromiseWithErr(this.fetchOverviewRaw()) @@ -123,7 +124,7 @@ export default class StudioServer { public urlFor(id: string, category: "layers" | "themes", uid?: number) { uid ??= this._userId.data - const uidStr = uid !== undefined ? "/" + uid : "" + const uidStr = uid !== null ? "/" + uid : "" return `${this.url}${uidStr}/${category}/${id}/${id}.json` } } diff --git a/src/UI/StudioGUI.svelte b/src/UI/StudioGUI.svelte index 2728d956a..5249cdf6d 100644 --- a/src/UI/StudioGUI.svelte +++ b/src/UI/StudioGUI.svelte @@ -31,12 +31,15 @@ import Add from "../assets/svg/Add.svelte" import { SearchIcon } from "@rgossiaux/svelte-heroicons/solid" import Hash from "../Logic/Web/Hash" + const directEntry = QueryParameters.GetBooleanQueryParameter("direct",false,"If set, write directly into the theme files") export let studioUrl = - window.location.hostname === "127.0.0.2" + window.location.hostname === "127.0.0.2" || directEntry.data ? "http://127.0.0.1:1235" : "https://studio.mapcomplete.org" + console.log("Using studio URL", studioUrl, "direct?", directEntry.data) + const oauth_token = QueryParameters.GetQueryParameter( "oauth_token", undefined, @@ -57,8 +60,8 @@ ) expertMode.addCallbackAndRunD((expert) => console.log("Expert mode is", expert)) const createdBy = osmConnection.userDetails.data.name - const uid = osmConnection.userDetails.map((ud) => ud?.uid) - const studio = new StudioServer(studioUrl, uid) + const uid = osmConnection.userDetails.map((ud) => directEntry.data ? null : ud?.uid, [directEntry]) + const studio = new StudioServer(studioUrl, uid, directEntry.data) let layersWithErr = studio.fetchOverview() let layerFilterTerm: string = "" @@ -285,7 +288,11 @@
Enable more options (expert mode) MapComplete version {version} -
{$uid}
+
{$uid} {studioUrl} + {#if $directEntry} + direct + {/if} +
{:else if state === "edit_layer"} @@ -368,7 +375,7 @@ {:else if state === "loading"}
- + Fetching information from {studioUrl}
{:else if state === "editing_layer"}