forked from MapComplete/MapComplete
Chore: formatting
This commit is contained in:
parent
35eff07c80
commit
c08fe03ed0
422 changed files with 31594 additions and 43019 deletions
|
|
@ -18,18 +18,26 @@
|
|||
|
||||
<div class="mt-12">
|
||||
{#if deleteState === "init"}
|
||||
<button on:click={() => {deleteState = "confirm"}} class="small">
|
||||
<button
|
||||
on:click={() => {
|
||||
deleteState = "confirm"
|
||||
}}
|
||||
class="small"
|
||||
>
|
||||
<TrashIcon class="h-6 w-6" />
|
||||
Delete this {objectType}
|
||||
Delete this {objectType}
|
||||
</button>
|
||||
{:else if deleteState === "confirm"}
|
||||
<div class="flex">
|
||||
<BackButton on:click={() => {deleteState = "init"}}>
|
||||
<BackButton
|
||||
on:click={() => {
|
||||
deleteState = "init"
|
||||
}}
|
||||
>
|
||||
Don't delete
|
||||
</BackButton>
|
||||
<NextButton clss="primary" on:click={() => deleteLayer()}>
|
||||
<div class="alert flex p-2">
|
||||
|
||||
<TrashIcon class="h-6 w-6" />
|
||||
Do delete this {objectType}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -81,8 +81,6 @@
|
|||
})
|
||||
|
||||
let highlightedItem: UIEventSource<HighlightedTagRendering> = state.highlightedItem
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div class="flex h-screen flex-col">
|
||||
|
|
@ -136,7 +134,7 @@
|
|||
General properties
|
||||
<ErrorIndicatorForRegion firstPaths={firstPathsFor("Basic")} {state} />
|
||||
</div>
|
||||
<div class="flex flex-col mb-8" slot="content0">
|
||||
<div class="mb-8 flex flex-col" slot="content0">
|
||||
<Region {state} configs={perRegion["Basic"]} />
|
||||
<DeleteButton {state} {backToStudio} objectType="layer" />
|
||||
</div>
|
||||
|
|
@ -189,15 +187,15 @@
|
|||
Below, you'll find the raw configuration file in `.json`-format. This is mostly for
|
||||
debugging purposes, but you can also edit the file directly if you want.
|
||||
</div>
|
||||
<div class="literal-code overflow-y-auto h-full" style="min-height: 75%">
|
||||
<div class="literal-code h-full overflow-y-auto" style="min-height: 75%">
|
||||
<RawEditor {state} />
|
||||
</div>
|
||||
<ShowConversionMessages messages={$messages} />
|
||||
|
||||
<div class="flex w-full flex-col">
|
||||
<div>
|
||||
The testobject (which is used to render the questions in the 'information panel'
|
||||
item has the following tags:
|
||||
The testobject (which is used to render the questions in the 'information panel' item
|
||||
has the following tags:
|
||||
</div>
|
||||
|
||||
<AllTagsPanel tags={state.testTags} />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
Conversion,
|
||||
ConversionMessage,
|
||||
DesugaringContext,
|
||||
Pipe
|
||||
Pipe,
|
||||
} from "../../Models/ThemeConfig/Conversion/Conversion"
|
||||
import { PrepareLayer } from "../../Models/ThemeConfig/Conversion/PrepareLayer"
|
||||
import { ValidateLayer, ValidateTheme } from "../../Models/ThemeConfig/Conversion/Validation"
|
||||
|
|
@ -69,7 +69,6 @@ export abstract class EditJsonState<T> {
|
|||
this.category = category
|
||||
this.expertMode = options?.expertMode ?? new UIEventSource<boolean>(false)
|
||||
|
||||
|
||||
const layerId = this.getId()
|
||||
this.configuration
|
||||
.mapD((config) => {
|
||||
|
|
@ -89,7 +88,6 @@ export abstract class EditJsonState<T> {
|
|||
await this.server.update(id, config, this.category)
|
||||
})
|
||||
this.messages = this.createMessagesStore()
|
||||
|
||||
}
|
||||
|
||||
public startSavingUpdates(enabled = true) {
|
||||
|
|
@ -158,10 +156,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",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,19 +231,21 @@ export abstract class EditJsonState<T> {
|
|||
|
||||
protected abstract getId(): Store<string>
|
||||
|
||||
protected abstract validate(configuration: Partial<T>): Promise<ConversionMessage[]>;
|
||||
protected abstract validate(configuration: Partial<T>): Promise<ConversionMessage[]>
|
||||
|
||||
/**
|
||||
* Creates a store that validates the configuration and which contains all relevant (error)-messages
|
||||
* @private
|
||||
*/
|
||||
private createMessagesStore(): Store<ConversionMessage[]> {
|
||||
return this.configuration.mapAsyncD(async (config) => {
|
||||
if(!this.validate){
|
||||
return []
|
||||
}
|
||||
return await this.validate(config)
|
||||
}).map(messages => messages ?? [])
|
||||
return this.configuration
|
||||
.mapAsyncD(async (config) => {
|
||||
if (!this.validate) {
|
||||
return []
|
||||
}
|
||||
return await this.validate(config)
|
||||
})
|
||||
.map((messages) => messages ?? [])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
|||
public readonly imageUploadManager = {
|
||||
getCountsFor() {
|
||||
return 0
|
||||
}
|
||||
},
|
||||
}
|
||||
public readonly layout: { getMatchingLayer: (key: any) => LayerConfig }
|
||||
public readonly featureSwitches: {
|
||||
|
|
@ -327,8 +327,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(
|
||||
|
|
@ -346,10 +346,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()
|
||||
|
|
@ -426,8 +426,9 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
|||
})
|
||||
}
|
||||
|
||||
protected async validate(configuration: Partial<LayerConfigJson>): Promise<ConversionMessage[]> {
|
||||
|
||||
protected async validate(
|
||||
configuration: Partial<LayerConfigJson>
|
||||
): Promise<ConversionMessage[]> {
|
||||
const layers = AllSharedLayers.getSharedLayersConfigs()
|
||||
|
||||
const questions = layers.get("questions")
|
||||
|
|
@ -437,7 +438,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
|||
}
|
||||
const state: DesugaringContext = {
|
||||
tagRenderings: sharedQuestions,
|
||||
sharedLayers: layers
|
||||
sharedLayers: layers,
|
||||
}
|
||||
const prepare = this.buildValidation(state)
|
||||
const context = ConversionContext.construct([], ["prepare"])
|
||||
|
|
@ -475,7 +476,7 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> {
|
|||
/** Applies a few bandaids to get everything smoothed out in case of errors; a big bunch of hacks basically
|
||||
*/
|
||||
public setupFixers() {
|
||||
this.configuration.addCallbackAndRunD(config => {
|
||||
this.configuration.addCallbackAndRunD((config) => {
|
||||
if (config.layers) {
|
||||
// Remove 'null' and 'undefined' values from the layer array if any are found
|
||||
for (let i = config.layers.length; i >= 0; i--) {
|
||||
|
|
@ -488,17 +489,16 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> {
|
|||
}
|
||||
|
||||
protected async validate(configuration: Partial<LayoutConfigJson>) {
|
||||
|
||||
const layers = AllSharedLayers.getSharedLayersConfigs()
|
||||
|
||||
for (const l of configuration.layers ?? []) {
|
||||
if(typeof l !== "string"){
|
||||
if (typeof l !== "string") {
|
||||
continue
|
||||
}
|
||||
if (!l.startsWith("https://")) {
|
||||
continue
|
||||
}
|
||||
const config = <LayerConfigJson> await Utils.downloadJsonCached(l, 1000*60*10)
|
||||
const config = <LayerConfigJson>await Utils.downloadJsonCached(l, 1000 * 60 * 10)
|
||||
layers.set(l, config)
|
||||
}
|
||||
|
||||
|
|
@ -509,11 +509,11 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> {
|
|||
}
|
||||
const state: DesugaringContext = {
|
||||
tagRenderings: sharedQuestions,
|
||||
sharedLayers: layers
|
||||
sharedLayers: layers,
|
||||
}
|
||||
const prepare = this.buildValidation(state)
|
||||
const context = ConversionContext.construct([], ["prepare"])
|
||||
if(configuration.layers){
|
||||
if (configuration.layers) {
|
||||
Utils.NoNullInplace(configuration.layers)
|
||||
}
|
||||
try {
|
||||
|
|
@ -524,5 +524,4 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> {
|
|||
}
|
||||
return context.messages
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,40 +22,37 @@
|
|||
export let selfLayers: { owner: number; id: string }[]
|
||||
export let otherLayers: { owner: number; id: string }[]
|
||||
{
|
||||
|
||||
/**
|
||||
* We modify the schema and inject options for self-declared layers
|
||||
*/
|
||||
|
||||
const layerSchema = schema.find(l => l.path.join(".") === "layers")
|
||||
const suggestions: { if: string, then: string }[] = layerSchema.hints.suggestions
|
||||
suggestions.unshift(...selfLayers.map(
|
||||
l => ({
|
||||
const layerSchema = schema.find((l) => l.path.join(".") === "layers")
|
||||
const suggestions: { if: string; then: string }[] = layerSchema.hints.suggestions
|
||||
suggestions.unshift(
|
||||
...selfLayers.map((l) => ({
|
||||
if: `value=https://studio.mapcomplete.org/${l.owner}/layers/${l.id}/${l.id}.json`,
|
||||
then: `<b>${l.id}</b> (made by you)`
|
||||
})
|
||||
))
|
||||
then: `<b>${l.id}</b> (made by you)`,
|
||||
}))
|
||||
)
|
||||
|
||||
for (let i = 0; i < otherLayers.length; i++) {
|
||||
const l = otherLayers[i]
|
||||
const mapping = {
|
||||
if: `value=https://studio.mapcomplete.org/${l.owner}/layers/${l.id}/${l.id}.json`,
|
||||
then: `<b>${l.id}</b> (made by ${l.owner})`
|
||||
then: `<b>${l.id}</b> (made by ${l.owner})`,
|
||||
}
|
||||
/**
|
||||
* This is a filthy hack which is time-sensitive and will break
|
||||
* It downloads the username and patches the suggestion, assuming that the list with all layers will be shown a while _after_ loading the view.
|
||||
* Caching in 'getInformationAboutUser' helps with this as well
|
||||
*/
|
||||
osmConnection.getInformationAboutUser(l.owner).then(userInfo => {
|
||||
osmConnection.getInformationAboutUser(l.owner).then((userInfo) => {
|
||||
mapping.then = `<b>${l.id}</b> (made by ${userInfo.display_name})`
|
||||
})
|
||||
suggestions.push(mapping)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
let messages = state.messages
|
||||
let hasErrors = messages.map(
|
||||
(m: ConversionMessage[]) => m.filter((m) => m.level === "error").length
|
||||
|
|
@ -102,8 +99,7 @@
|
|||
<div slot="content0" class="mb-8">
|
||||
<Region configs={perRegion["basic"]} path={[]} {state} title="Basic properties" />
|
||||
<Region configs={perRegion["start_location"]} path={[]} {state} title="Start location" />
|
||||
<DeleteButton {state} {backToStudio} objectType="theme"/>
|
||||
|
||||
<DeleteButton {state} {backToStudio} objectType="theme" />
|
||||
</div>
|
||||
|
||||
<div slot="title1">Layers</div>
|
||||
|
|
@ -126,10 +122,11 @@
|
|||
Below, you'll find the raw configuration file in `.json`-format. This is mostly for
|
||||
debugging purposes, but you can also edit the file directly if you want.
|
||||
</div>
|
||||
<div class="literal-code overflow-y-auto h-full" style="min-height: 75%">
|
||||
<div class="literal-code h-full overflow-y-auto" style="min-height: 75%">
|
||||
<RawEditor {state} />
|
||||
</div>
|
||||
<ShowConversionMessages messages={$messages} />
|
||||
</div>
|
||||
</TabbedGroup>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
{/if}
|
||||
</NextButton>
|
||||
{#if description}
|
||||
<Markdown src={description}/>
|
||||
<Markdown src={description} />
|
||||
{/if}
|
||||
{#each $messages as message}
|
||||
<ShowConversionMessage {message} />
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
<h3>{schema.path.at(-1)}</h3>
|
||||
|
||||
{#if subparts.length > 0}
|
||||
<Markdown src={schema.description}/>
|
||||
<Markdown src={schema.description} />
|
||||
{/if}
|
||||
{#if $currentValue === undefined}
|
||||
No array defined
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
type = type.substring(0, type.length - 2)
|
||||
}
|
||||
|
||||
const configJson: QuestionableTagRenderingConfigJson & {questionHintIsMd: boolean} = {
|
||||
const configJson: QuestionableTagRenderingConfigJson & { questionHintIsMd: boolean } = {
|
||||
id: path.join("_"),
|
||||
render: rendervalue,
|
||||
question: schema.hints.question,
|
||||
|
|
|
|||
|
|
@ -40,9 +40,10 @@
|
|||
if (lastIsString) {
|
||||
types.splice(types.length - 1, 1)
|
||||
}
|
||||
const configJson: QuestionableTagRenderingConfigJson & {questionHintIsMd: boolean}= {
|
||||
const configJson: QuestionableTagRenderingConfigJson & { questionHintIsMd: boolean } = {
|
||||
id: "TYPE_OF:" + path.join("_"),
|
||||
question: schema.hints.question ?? "Which subcategory is needed for " + schema.path.at(-1) + "?",
|
||||
question:
|
||||
schema.hints.question ?? "Which subcategory is needed for " + schema.path.at(-1) + "?",
|
||||
questionHint: schema.description,
|
||||
questionHintIsMd: true,
|
||||
mappings: types
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ import Hash from "../../Logic/Web/Hash"
|
|||
|
||||
export default class StudioHashSetter {
|
||||
constructor(mode: "layer" | "theme", tab: Store<number>, name: Store<string>) {
|
||||
tab.mapD(tab => {
|
||||
tab.mapD(
|
||||
(tab) => {
|
||||
Hash.hash.setData(mode + "/" + name.data + "/" + tab)
|
||||
}
|
||||
, [name])
|
||||
},
|
||||
[name]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,13 @@ import { LayoutConfigJson } from "../../Models/ThemeConfig/Json/LayoutConfigJson
|
|||
export default class StudioServer {
|
||||
private readonly url: string
|
||||
private readonly _userId: Store<number>
|
||||
private readonly overview: UIEventSource<{
|
||||
success: { id: string; owner: number; category: "layers" | "themes" }[]
|
||||
} | { error: any } | undefined>
|
||||
private readonly overview: UIEventSource<
|
||||
| {
|
||||
success: { id: string; owner: number; category: "layers" | "themes" }[]
|
||||
}
|
||||
| { error: any }
|
||||
| undefined
|
||||
>
|
||||
|
||||
constructor(url: string, userId: Store<number>) {
|
||||
this.url = url
|
||||
|
|
@ -21,9 +25,13 @@ export default class StudioServer {
|
|||
this.overview = UIEventSource.FromPromiseWithErr(this.fetchOverviewRaw())
|
||||
}
|
||||
|
||||
public fetchOverview(): Store<{
|
||||
success: { id: string; owner: number; category: "layers" | "themes" }[]
|
||||
} | { error } | undefined> {
|
||||
public fetchOverview(): Store<
|
||||
| {
|
||||
success: { id: string; owner: number; category: "layers" | "themes" }[]
|
||||
}
|
||||
| { error }
|
||||
| undefined
|
||||
> {
|
||||
return this.overview
|
||||
}
|
||||
|
||||
|
|
@ -80,11 +88,15 @@ export default class StudioServer {
|
|||
return
|
||||
}
|
||||
await fetch(this.urlFor(id, category), {
|
||||
method: "DELETE"
|
||||
method: "DELETE",
|
||||
})
|
||||
const overview: { id: string; owner: number; category: "layers" | "themes" }[] = this.overview.data?.["success"]
|
||||
const overview: { id: string; owner: number; category: "layers" | "themes" }[] =
|
||||
this.overview.data?.["success"]
|
||||
if (overview) {
|
||||
const index = overview.findIndex(obj => obj.id === id && obj.category === category && obj.owner === this._userId.data)
|
||||
const index = overview.findIndex(
|
||||
(obj) =>
|
||||
obj.id === id && obj.category === category && obj.owner === this._userId.data
|
||||
)
|
||||
if (index >= 0) {
|
||||
overview.splice(index, 1)
|
||||
this.overview.ping()
|
||||
|
|
@ -99,9 +111,9 @@ export default class StudioServer {
|
|||
await fetch(this.urlFor(id, category), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json;charset=utf-8"
|
||||
"Content-Type": "application/json;charset=utf-8",
|
||||
},
|
||||
body: config
|
||||
body: config,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
import type { ConfigMeta } from "./configMeta"
|
||||
import type {
|
||||
MappingConfigJson,
|
||||
QuestionableTagRenderingConfigJson
|
||||
QuestionableTagRenderingConfigJson,
|
||||
} from "../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
|
||||
import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig"
|
||||
import TagRenderingEditable from "../Popup/TagRendering/TagRenderingEditable.svelte"
|
||||
|
|
@ -59,8 +59,8 @@
|
|||
labelMapping = {
|
||||
if: "value=" + label,
|
||||
then: {
|
||||
en: "Builtin collection <b>" + label + "</b>:"
|
||||
}
|
||||
en: "Builtin collection <b>" + label + "</b>:",
|
||||
},
|
||||
}
|
||||
perLabel[label] = labelMapping
|
||||
mappingsBuiltin.push(labelMapping)
|
||||
|
|
@ -72,14 +72,14 @@
|
|||
mappingsBuiltin.push({
|
||||
if: "value=" + tr["id"],
|
||||
then: {
|
||||
en: "Builtin <b>" + tr["id"] + "</b> <div class='subtle'>" + description + "</div>"
|
||||
}
|
||||
en: "Builtin <b>" + tr["id"] + "</b> <div class='subtle'>" + description + "</div>",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const configBuiltin = new TagRenderingConfig(<QuestionableTagRenderingConfigJson>{
|
||||
question: "Which builtin element should be shown?",
|
||||
mappings: mappingsBuiltin
|
||||
mappings: mappingsBuiltin,
|
||||
})
|
||||
|
||||
const tags = new UIEventSource({ value })
|
||||
|
|
@ -112,7 +112,7 @@
|
|||
"condition",
|
||||
"metacondition",
|
||||
"mappings",
|
||||
"icon"
|
||||
"icon",
|
||||
])
|
||||
const ignored = new Set(["labels", "description", "classes"])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue