forked from MapComplete/MapComplete
Chore: housekeeping, linting
This commit is contained in:
parent
f942529755
commit
30d00eb06d
74 changed files with 998 additions and 623 deletions
|
|
@ -20,16 +20,13 @@
|
|||
export let ids: Store<string[] | undefined>
|
||||
export let state: SpecialVisualizationState
|
||||
export let options: {
|
||||
target_layer_id: string,
|
||||
targetTagRendering: string,
|
||||
text: string,
|
||||
icon: string,
|
||||
target_layer_id: string
|
||||
targetTagRendering: string
|
||||
text: string
|
||||
icon: string
|
||||
}
|
||||
let buttonState: UIEventSource<
|
||||
"idle" | "running" | "done" | { error: string }
|
||||
> = new UIEventSource<
|
||||
"idle" | "running" | "done" | { error: string }
|
||||
>("idle")
|
||||
let buttonState: UIEventSource<"idle" | "running" | "done" | { error: string }> =
|
||||
new UIEventSource<"idle" | "running" | "done" | { error: string }>("idle")
|
||||
let tagRenderingConfig: TagRenderingConfig
|
||||
let appliedNumberOfFeatures = new UIEventSource<number>(0)
|
||||
|
||||
|
|
@ -40,23 +37,22 @@
|
|||
|
||||
const mlmap = new UIEventSource(undefined)
|
||||
const mla = new MapLibreAdaptor(mlmap, {
|
||||
rasterLayer: state.mapProperties.rasterLayer
|
||||
rasterLayer: state.mapProperties.rasterLayer,
|
||||
})
|
||||
mla.allowZooming.setData(false)
|
||||
mla.allowMoving.setData(false)
|
||||
|
||||
const features = ids.mapD(ids => ids.map((id) =>
|
||||
state.indexedFeatures.featuresById.data.get(id)
|
||||
))
|
||||
|
||||
const features = ids.mapD((ids) =>
|
||||
ids.map((id) => state.indexedFeatures.featuresById.data.get(id))
|
||||
)
|
||||
|
||||
new ShowDataLayer(mlmap, {
|
||||
features: StaticFeatureSource.fromGeojson(features),
|
||||
zoomToFeatures: true,
|
||||
layer: layer.layerDef
|
||||
layer: layer.layerDef,
|
||||
})
|
||||
|
||||
features.addCallbackAndRunD(f => console.log("Features are now", f))
|
||||
features.addCallbackAndRunD((f) => console.log("Features are now", f))
|
||||
|
||||
async function applyAllChanges() {
|
||||
buttonState.set("running")
|
||||
|
|
@ -77,8 +73,8 @@
|
|||
if (specialRenderings.length == 0) {
|
||||
console.warn(
|
||||
"AutoApply: feature " +
|
||||
targetFeatureId +
|
||||
" got a rendering without supported auto actions:",
|
||||
targetFeatureId +
|
||||
" got a rendering without supported auto actions:",
|
||||
rendering
|
||||
)
|
||||
}
|
||||
|
|
@ -88,12 +84,7 @@
|
|||
continue
|
||||
}
|
||||
const action = <AutoAction>specialRendering.func
|
||||
await action.applyActionOn(
|
||||
feature,
|
||||
state,
|
||||
featureTags,
|
||||
specialRendering.args
|
||||
)
|
||||
await action.applyActionOn(feature, state, featureTags, specialRendering.args)
|
||||
}
|
||||
appliedOn.push(targetFeatureId)
|
||||
if (i % 50 === 0) {
|
||||
|
|
@ -117,13 +108,13 @@
|
|||
}
|
||||
|
||||
const t = Translations.t.general.add.import
|
||||
|
||||
</script>
|
||||
|
||||
{#if !state.theme.official && !state.featureSwitchIsTesting.data}
|
||||
<div class="alert">The auto-apply button is only available in official themes (or in testing mode)</div>
|
||||
<div class="alert">
|
||||
The auto-apply button is only available in official themes (or in testing mode)
|
||||
</div>
|
||||
<Tr t={t.howToTest} />
|
||||
|
||||
{:else if ids === undefined}
|
||||
<Loading>Gathering which elements support auto-apply...</Loading>
|
||||
{:else if tagRenderingConfig === undefined}
|
||||
|
|
@ -132,7 +123,6 @@
|
|||
<div>No elements found to perform action</div>
|
||||
{:else if $buttonState.error !== undefined}
|
||||
<div class="flex flex-col">
|
||||
|
||||
<div class="alert">Something went wrong</div>
|
||||
<div>{$buttonState.error}</div>
|
||||
</div>
|
||||
|
|
@ -144,7 +134,11 @@
|
|||
</Loading>
|
||||
{:else if $buttonState === "idle"}
|
||||
<div class="flex flex-col">
|
||||
<button on:click={() => {applyAllChanges()}}>
|
||||
<button
|
||||
on:click={() => {
|
||||
applyAllChanges()
|
||||
}}
|
||||
>
|
||||
<img class="h-8 w-8" alt="" src={options.icon} />
|
||||
{options.text}
|
||||
</button>
|
||||
|
|
@ -156,7 +150,6 @@
|
|||
<div class="subtle link-underline">
|
||||
The following objects will be updated:
|
||||
<div class="flex flex-wrap gap-x-2">
|
||||
|
||||
{#each $ids as featId}
|
||||
{#if layer.layerDef.source.geojsonSource === undefined}
|
||||
<a href={"https://openstreetmap.org/" + featId} target="_blank">{featId}</a>
|
||||
|
|
@ -172,8 +165,3 @@
|
|||
{:else}
|
||||
<div>Not supposed to show this... AutoApplyButton has invalid buttonstate: {$buttonState}</div>
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue