forked from MapComplete/MapComplete
Chore: linting
This commit is contained in:
parent
4625ad9a5c
commit
097141f944
307 changed files with 5346 additions and 2147 deletions
|
|
@ -38,7 +38,7 @@
|
|||
tags.data,
|
||||
{
|
||||
theme: state.layout.id,
|
||||
changeType: "import"
|
||||
changeType: "import",
|
||||
}
|
||||
)
|
||||
await state.changes.applyChanges(await change.CreateChangeDescriptions())
|
||||
|
|
@ -47,43 +47,51 @@
|
|||
|
||||
let _country = $tags["_country"]
|
||||
let mockPropertiesOsm = { id: feature.properties.id, [key]: $tags[key], _country }
|
||||
let mockPropertiesExternal = { id: feature.properties.id, [key]: externalProperties[key], _country }
|
||||
let trsWithKeys = layer.tagRenderings.filter(tr => {
|
||||
const keys: string[] = [].concat(...tr.usedTags().map(t => t.usedKeys()))
|
||||
let mockPropertiesExternal = {
|
||||
id: feature.properties.id,
|
||||
[key]: externalProperties[key],
|
||||
_country,
|
||||
}
|
||||
let trsWithKeys = layer.tagRenderings.filter((tr) => {
|
||||
const keys: string[] = [].concat(...tr.usedTags().map((t) => t.usedKeys()))
|
||||
return keys.indexOf(key) >= 0
|
||||
})
|
||||
let renderingBoth = trsWithKeys.find(tr => tr.IsKnown(mockPropertiesOsm) && tr.IsKnown(mockPropertiesExternal))
|
||||
let renderingExternal = renderingBoth ?? trsWithKeys.find(tr => tr.IsKnown(mockPropertiesExternal))
|
||||
let renderingBoth = trsWithKeys.find(
|
||||
(tr) => tr.IsKnown(mockPropertiesOsm) && tr.IsKnown(mockPropertiesExternal)
|
||||
)
|
||||
let renderingExternal =
|
||||
renderingBoth ?? trsWithKeys.find((tr) => tr.IsKnown(mockPropertiesExternal))
|
||||
let onOverwrite = false
|
||||
const t = Translations.t.external
|
||||
</script>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="py-1 px-2 interactive flex w-full justify-between">
|
||||
<div class="interactive flex w-full justify-between py-1 px-2">
|
||||
<div class="flex flex-col">
|
||||
|
||||
<div>
|
||||
|
||||
{#if renderingExternal}
|
||||
<TagRenderingAnswer tags={new UIEventSource(mockPropertiesExternal)} selectedElement={feature}
|
||||
config={renderingExternal}
|
||||
{layer} {state} />
|
||||
<TagRenderingAnswer
|
||||
tags={new UIEventSource(mockPropertiesExternal)}
|
||||
selectedElement={feature}
|
||||
config={renderingExternal}
|
||||
{layer}
|
||||
{state}
|
||||
/>
|
||||
{:else}
|
||||
<div class="flex gap-x-1 items-center">
|
||||
<b>{key}</b>{externalProperties[key]}
|
||||
<div class="flex items-center gap-x-1">
|
||||
<b>{key}</b>
|
||||
{externalProperties[key]}
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if !readonly && ( $isTesting || $isDebug || $showTags === "yes" || $showTags === "always" || $showTags === "full")}
|
||||
{#if !readonly && ($isTesting || $isDebug || $showTags === "yes" || $showTags === "always" || $showTags === "full")}
|
||||
<div class="subtle text-sm">
|
||||
{#if $tags[key] !== undefined}
|
||||
<span>
|
||||
OSM:
|
||||
{key}={$tags[key]}
|
||||
</span>
|
||||
<span>
|
||||
OSM:
|
||||
{key}={$tags[key]}
|
||||
</span>
|
||||
{/if}
|
||||
<span>
|
||||
{key}= {externalProperties[key]}
|
||||
|
|
@ -92,21 +100,20 @@
|
|||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
{#if !readonly}
|
||||
{#if currentStep === "init"}
|
||||
<button class="small" on:click={() => apply(key)}
|
||||
|
||||
on:mouseover={() => onOverwrite = true}
|
||||
on:focus={() => onOverwrite = true}
|
||||
on:blur={() => onOverwrite = false}
|
||||
on:mouseout={() => onOverwrite = false }
|
||||
<button
|
||||
class="small"
|
||||
on:click={() => apply(key)}
|
||||
on:mouseover={() => (onOverwrite = true)}
|
||||
on:focus={() => (onOverwrite = true)}
|
||||
on:blur={() => (onOverwrite = false)}
|
||||
on:mouseout={() => (onOverwrite = false)}
|
||||
>
|
||||
{#if $tags[key]}
|
||||
<Tr t={t.overwrite} />
|
||||
{:else}
|
||||
<Tr t={t.apply} />
|
||||
|
||||
{/if}
|
||||
</button>
|
||||
{:else if currentStep === "applying"}
|
||||
|
|
@ -114,7 +121,6 @@
|
|||
{:else if currentStep === "done"}
|
||||
<div class="thanks">
|
||||
<Tr t={t.done} />
|
||||
|
||||
</div>
|
||||
{:else}
|
||||
<div class="alert">
|
||||
|
|
@ -122,22 +128,26 @@
|
|||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{#if $tags[key] && $tags[key] !== externalProperties[key]}
|
||||
<div class:glowing-shadow={onOverwrite}>
|
||||
<span class="subtle">
|
||||
<Tr t={t.currentInOsmIs} />
|
||||
</span>
|
||||
<span class="subtle">
|
||||
<Tr t={t.currentInOsmIs} />
|
||||
</span>
|
||||
{#if renderingBoth}
|
||||
<TagRenderingAnswer tags={new UIEventSource(mockPropertiesOsm)} selectedElement={feature} config={renderingBoth}
|
||||
{layer} {state} />
|
||||
<TagRenderingAnswer
|
||||
tags={new UIEventSource(mockPropertiesOsm)}
|
||||
selectedElement={feature}
|
||||
config={renderingBoth}
|
||||
{layer}
|
||||
{state}
|
||||
/>
|
||||
{:else}
|
||||
<div class="flex gap-x-2 items-center">
|
||||
<b>{key}</b> {$tags[key]}
|
||||
<div class="flex items-center gap-x-2">
|
||||
<b>{key}</b>
|
||||
{$tags[key]}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -49,32 +49,30 @@
|
|||
return osmProperties[k] === undefined && typeof externalProperties[k] === "string"
|
||||
})
|
||||
// let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
||||
let different = propertyKeysExternal.filter(
|
||||
(key) => {
|
||||
if (key.startsWith("_")) {
|
||||
return false
|
||||
}
|
||||
if (osmProperties[key] === undefined) {
|
||||
return false
|
||||
}
|
||||
if (typeof externalProperties[key] !== "string") {
|
||||
return false
|
||||
}
|
||||
if (osmProperties[key] === externalProperties[key]) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (key === "website") {
|
||||
const osmCanon = new URL(osmProperties[key]).toString()
|
||||
const externalCanon = new URL(externalProperties[key]).toString()
|
||||
if (osmCanon === externalCanon) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
let different = propertyKeysExternal.filter((key) => {
|
||||
if (key.startsWith("_")) {
|
||||
return false
|
||||
}
|
||||
)
|
||||
if (osmProperties[key] === undefined) {
|
||||
return false
|
||||
}
|
||||
if (typeof externalProperties[key] !== "string") {
|
||||
return false
|
||||
}
|
||||
if (osmProperties[key] === externalProperties[key]) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (key === "website") {
|
||||
const osmCanon = new URL(osmProperties[key]).toString()
|
||||
const externalCanon = new URL(externalProperties[key]).toString()
|
||||
if (osmCanon === externalCanon) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
let currentStep: "init" | "applying_all" | "all_applied" = "init"
|
||||
let applyAllHovered = false
|
||||
|
|
@ -84,12 +82,13 @@
|
|||
const tagsToApply = missing.map((k) => new Tag(k, externalProperties[k]))
|
||||
const change = new ChangeTagAction(tags.data.id, new And(tagsToApply), tags.data, {
|
||||
theme: state.layout.id,
|
||||
changeType: "import"
|
||||
changeType: "import",
|
||||
})
|
||||
await state.changes.applyChanges(await change.CreateChangeDescriptions())
|
||||
currentStep = "all_applied"
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if propertyKeysExternal.length === 0 && knownImages.size + unknownImages.length === 0}
|
||||
<Tr cls="subtle" t={t.noDataLoaded} />
|
||||
{:else if unknownImages.length === 0 && missing.length === 0 && different.length === 0}
|
||||
|
|
@ -98,9 +97,9 @@
|
|||
<Tr t={t.allIncluded} />
|
||||
</div>
|
||||
{:else}
|
||||
<div class="low-interaction p-1 border-interactive">
|
||||
<div class="low-interaction border-interactive p-1">
|
||||
{#if !readonly}
|
||||
<Tr t={t.loadedFrom.Subs({url: sourceUrl, source: sourceUrl})} />
|
||||
<Tr t={t.loadedFrom.Subs({ url: sourceUrl, source: sourceUrl })} />
|
||||
<h3>
|
||||
<Tr t={t.conflicting.title} />
|
||||
</h3>
|
||||
|
|
@ -113,25 +112,41 @@
|
|||
{#if different.length > 0}
|
||||
{#each different as key}
|
||||
<div class="mx-2 rounded-2xl">
|
||||
<ComparisonAction {key} {state} {tags} {externalProperties} {layer} {feature} {readonly} />
|
||||
<ComparisonAction
|
||||
{key}
|
||||
{state}
|
||||
{tags}
|
||||
{externalProperties}
|
||||
{layer}
|
||||
{feature}
|
||||
{readonly}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if missing.length > 0}
|
||||
{#if currentStep === "init"}
|
||||
|
||||
{#each missing as key}
|
||||
<div class:glowing-shadow={applyAllHovered} class="mx-2 rounded-2xl">
|
||||
<ComparisonAction {key} {state} {tags} {externalProperties} {layer} {feature} {readonly} />
|
||||
<ComparisonAction
|
||||
{key}
|
||||
{state}
|
||||
{tags}
|
||||
{externalProperties}
|
||||
{layer}
|
||||
{feature}
|
||||
{readonly}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
{#if !readonly && missing.length > 1}
|
||||
<button on:click={() => applyAllMissing()}
|
||||
on:mouseover={() => applyAllHovered = true}
|
||||
on:focus={() => applyAllHovered = true}
|
||||
on:blur={() => applyAllHovered = false}
|
||||
on:mouseout={() => applyAllHovered = false }
|
||||
<button
|
||||
on:click={() => applyAllMissing()}
|
||||
on:mouseover={() => (applyAllHovered = true)}
|
||||
on:focus={() => (applyAllHovered = true)}
|
||||
on:blur={() => (applyAllHovered = false)}
|
||||
on:mouseout={() => (applyAllHovered = false)}
|
||||
>
|
||||
<Tr t={t.applyAll} />
|
||||
</button>
|
||||
|
|
@ -144,7 +159,6 @@
|
|||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
{#if unknownImages.length > 0}
|
||||
|
|
@ -166,13 +180,13 @@
|
|||
{tags}
|
||||
{state}
|
||||
image={{
|
||||
pictureUrl: image,
|
||||
provider: "Velopark",
|
||||
thumbUrl: image,
|
||||
details: undefined,
|
||||
coordinates: undefined,
|
||||
osmTags: { image },
|
||||
}}
|
||||
pictureUrl: image,
|
||||
provider: "Velopark",
|
||||
thumbUrl: image,
|
||||
details: undefined,
|
||||
coordinates: undefined,
|
||||
osmTags: { image },
|
||||
}}
|
||||
{feature}
|
||||
{layer}
|
||||
/>
|
||||
|
|
@ -181,10 +195,8 @@
|
|||
{/if}
|
||||
{#if externalProperties["_last_edit_timestamp"] !== undefined}
|
||||
<span class="subtle text-sm">
|
||||
|
||||
External data has been last modified on {externalProperties["_last_edit_timestamp"]}
|
||||
External data has been last modified on {externalProperties["_last_edit_timestamp"]}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,39 @@
|
|||
<script lang="ts">
|
||||
/**
|
||||
* The comparison tool loads json-data from a speficied URL, eventually post-processes it
|
||||
* and compares it with the current object
|
||||
*/
|
||||
import Loading from "../Base/Loading.svelte"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import ComparisonTable from "./ComparisonTable.svelte"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import type { Feature } from "geojson"
|
||||
import type { OsmTags } from "../../Models/OsmFeature"
|
||||
import Translations from "../i18n/Translations"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
/**
|
||||
* The comparison tool loads json-data from a speficied URL, eventually post-processes it
|
||||
* and compares it with the current object
|
||||
*/
|
||||
import Loading from "../Base/Loading.svelte"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import ComparisonTable from "./ComparisonTable.svelte"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import type { Feature } from "geojson"
|
||||
import type { OsmTags } from "../../Models/OsmFeature"
|
||||
import Translations from "../i18n/Translations"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
|
||||
export let externalData: Store<{ success: {content: Record<string, string> } } | { error: string } | undefined | null /* null if no URL is found, undefined if loading*/>
|
||||
export let state: SpecialVisualizationState
|
||||
export let tags: UIEventSource<OsmTags>
|
||||
export let layer: LayerConfig
|
||||
export let feature: Feature
|
||||
export let readonly = false
|
||||
export let sourceUrl: Store<string>
|
||||
|
||||
export let externalData: Store<
|
||||
| { success: { content: Record<string, string> } }
|
||||
| { error: string }
|
||||
| undefined
|
||||
| null /* null if no URL is found, undefined if loading*/
|
||||
>
|
||||
export let state: SpecialVisualizationState
|
||||
export let tags: UIEventSource<OsmTags>
|
||||
export let layer: LayerConfig
|
||||
export let feature: Feature
|
||||
export let readonly = false
|
||||
export let sourceUrl: Store<string>
|
||||
</script>
|
||||
|
||||
{#if !$sourceUrl}
|
||||
<!-- empty block -->
|
||||
{:else if $externalData === undefined}
|
||||
<Loading/>
|
||||
<Loading />
|
||||
{:else if $externalData["error"] !== undefined}
|
||||
<div class="alert flex">
|
||||
<Tr t={Translations.t.general.error}/>
|
||||
<Tr t={Translations.t.general.error} />
|
||||
{$externalData["error"]}
|
||||
</div>
|
||||
{:else if $externalData["success"] !== undefined}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue