chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2024-10-19 14:44:55 +02:00
parent c9ce29f206
commit 40e894df8b
294 changed files with 14209 additions and 4192 deletions

View file

@ -44,8 +44,8 @@
let indexInToAdd = 0
for (let i = 0; i < newPath.length; i++) {
if(newPath[i] === toAdd[indexInToAdd]){
indexInToAdd ++
if (newPath[i] === toAdd[indexInToAdd]) {
indexInToAdd++
}
}

View file

@ -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"
@ -98,7 +98,6 @@ export abstract class EditJsonState<T> {
public startSavingUpdates(enabled = true) {
this.sendingUpdates = enabled
if (!this.server.isDirect) {
this.register(
["credits"],
this.osmConnection.userDetails.mapD((u) => u.name),
@ -177,10 +176,10 @@ export abstract class EditJsonState<T> {
path,
type: "translation",
hints: {
typehint: "translation"
typehint: "translation",
},
required: origConfig.required ?? false,
description: origConfig.description ?? "A translatable object"
description: origConfig.description ?? "A translatable object",
}
}
@ -332,7 +331,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
public readonly imageUploadManager = {
getCountsFor() {
return 0
}
},
}
public readonly theme: { getMatchingLayer: (key: any) => LayerConfig }
public readonly featureSwitches: {
@ -348,8 +347,8 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
properties: this.testTags.data,
geometry: {
type: "Point",
coordinates: [3.21, 51.2]
}
coordinates: [3.21, 51.2],
},
}
constructor(
@ -366,10 +365,10 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
} catch (e) {
return undefined
}
}
},
}
this.featureSwitches = {
featureSwitchIsDebugging: new UIEventSource<boolean>(true)
featureSwitchIsDebugging: new UIEventSource<boolean>(true),
}
this.addMissingTagRenderingIds()
@ -459,7 +458,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
const state: DesugaringContext = {
tagRenderings: sharedQuestions,
sharedLayers: layers,
tagRenderingOrder: []
tagRenderingOrder: [],
}
const prepare = this.buildValidation(state)
const context = ConversionContext.construct([], ["prepare"])
@ -536,7 +535,7 @@ export class EditThemeState extends EditJsonState<ThemeConfigJson> {
const state: DesugaringContext = {
tagRenderings: sharedQuestions,
sharedLayers: layers,
tagRenderingOrder: []
tagRenderingOrder: [],
}
const prepare = this.buildValidation(state)
const context = ConversionContext.construct([], ["prepare"])

View file

@ -5,9 +5,7 @@
import { TrashIcon } from "@babeard/svelte-heroicons/mini"
import ShowConversionMessage from "./ShowConversionMessage.svelte"
import Markdown from "../Base/Markdown.svelte"
import type {
QuestionableTagRenderingConfigJson
} from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import type { QuestionableTagRenderingConfigJson } from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import CollapsedTagRenderingPreview from "./CollapsedTagRenderingPreview.svelte"
import { Accordion } from "flowbite-svelte"
import { Utils } from "../../Utils"
@ -17,7 +15,6 @@
let schema: ConfigMeta = state.getSchema(path)[0]
console.log("SBA got schema", schema, "for path", path)
let title = schema?.path?.at(-1)
let singular = title
if (title?.endsWith("s")) {
@ -69,6 +66,7 @@
currentValue.ping()
}
</script>
{#if schema !== undefined}
<div class="pl-2">
<h3>{schema.path.at(-1)}</h3>
@ -97,15 +95,16 @@
<button
class="h-fit w-fit rounded-full border border-black p-1"
on:click={() => {
del(i)
}}
del(i)
}}
>
<TrashIcon class="h-4 w-4" />
</button>
</div>
{/each}
{:else}
<Accordion> <!-- The CollapsedTagRenderingPreview contains the accordeon items -->
<Accordion>
<!-- The CollapsedTagRenderingPreview contains the accordeon items -->
{#each $currentValue as value, i}
<CollapsedTagRenderingPreview
{state}
@ -125,8 +124,8 @@
{#if path.length === 1 && path[0] === "tagRenderings"}
<button
on:click={() => {
createItem("images")
}}
createItem("images")
}}
>
Add a builtin tagRendering
</button>

View file

@ -32,14 +32,14 @@
return type.some((t) => mightBeBoolean(t))
}
function mightBeTag(){
function mightBeTag() {
const t = schema.type
if(!Array.isArray(t)){
if (!Array.isArray(t)) {
return false
}
const hasAnd = t.some(obj => obj["$ref"] === "#/definitions/{and:TagConfigJson[];}")
const hasOr = t.some(obj => obj["$ref"] === "#/definitions/{or:TagConfigJson[];}")
const hasString = t.some(obj => obj["type"] === "string")
const hasAnd = t.some((obj) => obj["$ref"] === "#/definitions/{and:TagConfigJson[];}")
const hasOr = t.some((obj) => obj["$ref"] === "#/definitions/{or:TagConfigJson[];}")
const hasString = t.some((obj) => obj["type"] === "string")
return hasAnd && hasOr && hasString
}