Chore: formatting

This commit is contained in:
Pieter Vander Vennet 2024-06-16 16:06:26 +02:00
parent 35eff07c80
commit c08fe03ed0
422 changed files with 31594 additions and 43019 deletions

View file

@ -21,16 +21,14 @@
}
let knownValues: UIEventSource<string[]> = new UIEventSource<string[]>([])
tags.addCallbackAndRunD(tags => {
tags.addCallbackAndRunD((tags) => {
knownValues.setData(Object.keys(tags))
})
function reEvalKnownValues(){
function reEvalKnownValues() {
knownValues.setData(Object.keys(tags.data))
}
const metaKeys: string[] = [].concat(...SimpleMetaTaggers.metatags.map((k) => k.keys))
let allCalculatedTags = new Set<string>([...calculatedTags, ...metaKeys])
</script>
@ -54,7 +52,7 @@
{:else if $tags[key] === ""}
<i>Empty string</i>
{:else if typeof $tags[key] === "object"}
<div class="literal-code" >{JSON.stringify($tags[key])}</div>
<div class="literal-code">{JSON.stringify($tags[key])}</div>
{:else}
{$tags[key]}
{/if}

View file

@ -17,13 +17,13 @@ export class MinimapViz implements SpecialVisualization {
{
doc: "The (maximum) zoomlevel: the target zoomlevel after fitting the entire feature. The minimap will fit the entire feature, then zoom out to this zoom level. The higher, the more zoomed in with 1 being the entire world and 19 being really close",
name: "zoomlevel",
defaultValue: "18"
defaultValue: "18",
},
{
doc: "(Matches all resting arguments) This argument should be the key of a property of the feature. The corresponding value is interpreted as either the id or the a list of ID's. The features with these ID's will be shown on this minimap. (Note: if the key is 'id', list interpration is disabled)",
name: "idKey",
defaultValue: "id"
}
defaultValue: "id",
},
]
example: "`{minimap()}`, `{minimap(17, id, _list_of_embedded_feature_ids_calculated_by_calculated_tag):height:10rem; border: 2px solid black}`"
@ -82,13 +82,12 @@ export class MinimapViz implements SpecialVisualization {
const mla = new MapLibreAdaptor(mlmap, {
rasterLayer: state.mapProperties.rasterLayer,
zoom: new UIEventSource<number>(17),
maxzoom: new UIEventSource<number>(17)
maxzoom: new UIEventSource<number>(17),
})
mla.allowMoving.setData(false)
mla.allowZooming.setData(false)
mla.location.setData({lon, lat})
mla.location.setData({ lon, lat })
if (args[0]) {
const parsed = Number(args[0])
@ -96,19 +95,19 @@ export class MinimapViz implements SpecialVisualization {
mla.zoom.setData(parsed)
}
}
mlmap.addCallbackAndRun(map => console.log("Map for minimap vis is now", map))
mlmap.addCallbackAndRun((map) => console.log("Map for minimap vis is now", map))
ShowDataLayer.showMultipleLayers(
mlmap,
new StaticFeatureSource(featuresToShow),
state.layout.layers,
{zoomToFeatures: true}
{ zoomToFeatures: true }
)
return new SvelteUIElement(MaplibreMap, {
interactive: false,
map: mlmap,
mapProperties: mla
mapProperties: mla,
})
.SetClass("h-40 rounded")
.SetStyle("overflow: hidden; pointer-events: none;")

View file

@ -50,7 +50,6 @@
let questionboxElem: HTMLDivElement
let questionsToAsk = tags.map(
(tags) => {
const questionsToAsk: TagRenderingConfig[] = []
for (const baseQuestion of baseQuestions) {
if (skippedQuestions.data.has(baseQuestion.id)) {
@ -164,7 +163,13 @@
{#if $showAllQuestionsAtOnce}
<div class="flex flex-col gap-y-1">
{#each $allQuestionsToAsk as question (question.id)}
<TagRenderingQuestionDynamic config={question} {tags} {selectedElement} {state} {layer} />
<TagRenderingQuestionDynamic
config={question}
{tags}
{selectedElement}
{state}
{layer}
/>
{/each}
</div>
{:else if $firstQuestion !== undefined}

View file

@ -4,7 +4,7 @@
import Locale from "../../i18n/Locale"
import type {
RenderingSpecification,
SpecialVisualizationState
SpecialVisualizationState,
} from "../../SpecialVisualization"
import { Utils } from "../../../Utils.js"
import type { Feature } from "geojson"
@ -67,7 +67,7 @@
{#each specs as specpart}
{#if typeof specpart === "string"}
<span>
{@html Utils.purify(Utils.SubstituteKeys(specpart, $tags)) }
{@html Utils.purify(Utils.SubstituteKeys(specpart, $tags))}
<WeblateLink context={t.context} />
</span>
{:else if $tags !== undefined}
@ -79,7 +79,7 @@
{#each specs as specpart}
{#if typeof specpart === "string"}
<span>
{@html Utils.purify(Utils.SubstituteKeys(specpart, $tags)) }
{@html Utils.purify(Utils.SubstituteKeys(specpart, $tags))}
<WeblateLink context={t.context} />
</span>
{:else if $tags !== undefined}

View file

@ -1,5 +1,7 @@
<script lang="ts">
import TagRenderingConfig, { TagRenderingConfigUtils } from "../../../Models/ThemeConfig/TagRenderingConfig"
import TagRenderingConfig, {
TagRenderingConfigUtils,
} from "../../../Models/ThemeConfig/TagRenderingConfig"
import type { SpecialVisualizationState } from "../../SpecialVisualization"
import type { Feature } from "geojson"
import { UIEventSource } from "../../../Logic/UIEventSource"
@ -16,7 +18,14 @@
export let id: string = undefined
let dynamicConfig = TagRenderingConfigUtils.withNameSuggestionIndex(config, tags, selectedElement)
</script>
<TagRenderingAnswer {selectedElement} {layer} config={$dynamicConfig} {extraClasses} {id} {tags} {state} />
<TagRenderingAnswer
{selectedElement}
{layer}
config={$dynamicConfig}
{extraClasses}
{id}
{tags}
{state}
/>

View file

@ -1,5 +1,7 @@
<script lang="ts">
import TagRenderingConfig, { TagRenderingConfigUtils } from "../../../Models/ThemeConfig/TagRenderingConfig"
import TagRenderingConfig, {
TagRenderingConfigUtils,
} from "../../../Models/ThemeConfig/TagRenderingConfig"
import { Store, UIEventSource } from "../../../Logic/UIEventSource"
import type { Feature } from "geojson"
import type { SpecialVisualizationState } from "../../SpecialVisualization"
@ -19,8 +21,16 @@
export let editMode = !config.IsKnown(tags.data)
let dynamicConfig = TagRenderingConfigUtils.withNameSuggestionIndex(config, tags, selectedElement)
</script>
<TagRenderingEditable config={$dynamicConfig} {editMode} {clss} {highlightedRendering} {editingEnabled} {layer} {state}
{selectedElement} {tags} />
<TagRenderingEditable
config={$dynamicConfig}
{editMode}
{clss}
{highlightedRendering}
{editingEnabled}
{layer}
{state}
{selectedElement}
{tags}
/>

View file

@ -44,7 +44,7 @@
(search) => {
search = search?.trim()
if (!search) {
if(hideUnlessSearched){
if (hideUnlessSearched) {
if (mapping.priorityIf?.matchesProperties(tags.data)) {
return true
}

View file

@ -167,7 +167,11 @@
onDestroy(
freeformInput.subscribe((freeformValue) => {
if (!config?.mappings || config?.mappings?.length == 0 || config.freeform?.key === undefined) {
if (
!config?.mappings ||
config?.mappings?.length == 0 ||
config.freeform?.key === undefined
) {
return
}
// If a freeform value is given, mark the 'mapping' as marked
@ -232,7 +236,9 @@
// Add the extraTags to the existing And
selectedTags = new And([...selectedTags.and, ...extraTagsArray])
} else {
console.error("selectedTags is not of type Tag or And, it is a "+JSON.stringify(selectedTags))
console.error(
"selectedTags is not of type Tag or And, it is a " + JSON.stringify(selectedTags)
)
}
}
}
@ -289,7 +295,8 @@
let showTags = state?.userRelatedState?.showTags ?? new ImmutableStore(undefined)
let numberOfCs = state?.osmConnection?.userDetails?.data?.csCount ?? 0
let question = config.question
let hideMappingsUnlessSearchedFor = config.mappings.length > 8 && config.mappings.some(m => m.priorityIf)
let hideMappingsUnlessSearchedFor =
config.mappings.length > 8 && config.mappings.some((m) => m.priorityIf)
$: question = config.question
if (state?.osmConnection) {
onDestroy(
@ -343,15 +350,13 @@
/>
</div>
{#if hideMappingsUnlessSearchedFor}
<div class="rounded border border-black border-dashed p-1 px-2 m-1">
<Tr t={Translations.t.general.mappingsAreHidden}/>
<div class="m-1 rounded border border-dashed border-black p-1 px-2">
<Tr t={Translations.t.general.mappingsAreHidden} />
</div>
{/if}
{/if}
{#if config.freeform?.key && !(config?.mappings?.filter(m => m.hideInAnswer != true)?.length > 0)}
{#if config.freeform?.key && !(config?.mappings?.filter((m) => m.hideInAnswer != true)?.length > 0)}
<!-- There are no options to choose from, simply show the input element: fill out the text field -->
<FreeformInput
{config}
@ -505,7 +510,7 @@
<span class="flex flex-wrap">
{#if $featureSwitchIsTesting}
<button class="small" on:click={() => console.log("Configuration is ", config)}>
Testmode &nbsp;
Testmode &nbsp;
</button>
{/if}
{#if $featureSwitchIsTesting || $featureSwitchIsDebugging}

View file

@ -1,34 +1,36 @@
<script lang="ts">/**
* Wrapper around 'tagRenderingEditable' but might add mappings dynamically
*
* Note: does not forward the 'save-button'-slot
*/
import TagRenderingConfig, { TagRenderingConfigUtils } from "../../../Models/ThemeConfig/TagRenderingConfig"
import { UIEventSource } from "../../../Logic/UIEventSource"
import type { Feature } from "geojson"
import type { SpecialVisualizationState } from "../../SpecialVisualization"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import TagRenderingQuestion from "./TagRenderingQuestion.svelte"
import type { UploadableTag } from "../../../Logic/Tags/TagUtils"
import { writable } from "svelte/store"
import Translations from "../../i18n/Translations"
import { twJoin } from "tailwind-merge"
import Tr from "../../Base/Tr.svelte"
import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid"
<script lang="ts">
/**
* Wrapper around 'tagRenderingEditable' but might add mappings dynamically
*
* Note: does not forward the 'save-button'-slot
*/
import TagRenderingConfig, {
TagRenderingConfigUtils,
} from "../../../Models/ThemeConfig/TagRenderingConfig"
import { UIEventSource } from "../../../Logic/UIEventSource"
import type { Feature } from "geojson"
import type { SpecialVisualizationState } from "../../SpecialVisualization"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import TagRenderingQuestion from "./TagRenderingQuestion.svelte"
import type { UploadableTag } from "../../../Logic/Tags/TagUtils"
import { writable } from "svelte/store"
import Translations from "../../i18n/Translations"
import { twJoin } from "tailwind-merge"
import Tr from "../../Base/Tr.svelte"
import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid"
export let config: TagRenderingConfig
export let tags: UIEventSource<Record<string, string>>
export let config: TagRenderingConfig
export let tags: UIEventSource<Record<string, string>>
export let selectedElement: Feature
export let state: SpecialVisualizationState
export let layer: LayerConfig | undefined
export let selectedTags: UploadableTag = undefined
export let extraTags: UIEventSource<Record<string, string>> = new UIEventSource({})
export let selectedElement: Feature
export let state: SpecialVisualizationState
export let layer: LayerConfig | undefined
export let selectedTags: UploadableTag = undefined
export let extraTags: UIEventSource<Record<string, string>> = new UIEventSource({})
export let allowDeleteOfFreeform: boolean = false
export let allowDeleteOfFreeform: boolean = false
let dynamicConfig = TagRenderingConfigUtils.withNameSuggestionIndex(config, tags, selectedElement)
let dynamicConfig = TagRenderingConfigUtils.withNameSuggestionIndex(config, tags, selectedElement)
</script>
<TagRenderingQuestion