forked from MapComplete/MapComplete
Chore: formatting
This commit is contained in:
parent
35eff07c80
commit
c08fe03ed0
422 changed files with 31594 additions and 43019 deletions
|
@ -15,7 +15,6 @@
|
|||
import Translations from "../i18n/Translations"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
|
||||
|
||||
export let externalProperties: Record<string, string>
|
||||
delete externalProperties["@context"]
|
||||
console.log("External properties are", externalProperties)
|
||||
|
@ -33,51 +32,60 @@
|
|||
let externalKeys: string[] = Object.keys(externalProperties).sort()
|
||||
|
||||
const imageKeyRegex = /image|image:[0-9]+/
|
||||
let knownImages: Store<Set<string>> = tags.map(osmProperties => new Set(
|
||||
Object.keys(osmProperties)
|
||||
let knownImages: Store<Set<string>> = tags.map(
|
||||
(osmProperties) =>
|
||||
new Set(
|
||||
Object.keys(osmProperties)
|
||||
.filter((k) => k.match(imageKeyRegex))
|
||||
.map((k) => osmProperties[k])
|
||||
)
|
||||
)
|
||||
let unknownImages: Store<string[]> = knownImages.map((images) =>
|
||||
externalKeys
|
||||
.filter((k) => k.match(imageKeyRegex))
|
||||
.map((k) => osmProperties[k])
|
||||
))
|
||||
let unknownImages: Store<string[]> = knownImages.map(images => externalKeys
|
||||
.filter((k) => k.match(imageKeyRegex))
|
||||
.map((k) => externalProperties[k])
|
||||
.filter((i) => !images.has(i)))
|
||||
|
||||
.map((k) => externalProperties[k])
|
||||
.filter((i) => !images.has(i))
|
||||
)
|
||||
|
||||
let propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
|
||||
let missing: Store<string[]> = tags.map(osmProperties => propertyKeysExternal.filter((k) => {
|
||||
if (k.startsWith("_")) {
|
||||
return false
|
||||
}
|
||||
return osmProperties[k] === undefined && typeof externalProperties[k] === "string"
|
||||
}))
|
||||
// let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
||||
let different: Store<string[]> = tags.map(osmProperties => 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) {
|
||||
let missing: Store<string[]> = tags.map((osmProperties) =>
|
||||
propertyKeysExternal.filter((k) => {
|
||||
if (k.startsWith("_")) {
|
||||
return false
|
||||
}
|
||||
return osmProperties[k] === undefined && typeof externalProperties[k] === "string"
|
||||
})
|
||||
)
|
||||
// let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
||||
let different: Store<string[]> = tags.map((osmProperties) =>
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}))
|
||||
if (key === "website") {
|
||||
const osmCanon = new URL(osmProperties[key]).toString()
|
||||
const externalCanon = new URL(externalProperties[key]).toString()
|
||||
if (osmCanon === externalCanon) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
let hasDifferencesAtStart = (different.data.length + missing.data.length + unknownImages.data.length) > 0
|
||||
return true
|
||||
})
|
||||
)
|
||||
|
||||
let hasDifferencesAtStart =
|
||||
different.data.length + missing.data.length + unknownImages.data.length > 0
|
||||
|
||||
let currentStep: "init" | "applying_all" | "all_applied" = "init"
|
||||
let applyAllHovered = false
|
||||
|
@ -87,23 +95,23 @@
|
|||
const tagsToApply = missing.data.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 !hasDifferencesAtStart}
|
||||
<span class="subtle text-sm">
|
||||
<Tr t={t.allIncluded.Subs({source:sourceUrl})}/>
|
||||
<Tr t={t.allIncluded.Subs({ source: sourceUrl })} />
|
||||
</span>
|
||||
|
||||
{:else if $unknownImages.length === 0 && $missing.length === 0 && $different.length === 0}
|
||||
<div class="thanks m-0 flex items-center gap-x-2 px-2">
|
||||
<Party class="h-8 w-8 shrink-0" />
|
||||
<Tr t={t.allIncluded.Subs({source: sourceUrl})} />
|
||||
<Tr t={t.allIncluded.Subs({ source: sourceUrl })} />
|
||||
</div>
|
||||
{:else}
|
||||
<div class="low-interaction border-interactive p-1">
|
||||
|
@ -112,7 +120,6 @@
|
|||
{/if}
|
||||
|
||||
<div class="flex flex-col" class:gap-y-8={!readonly}>
|
||||
|
||||
{#if $different.length > 0}
|
||||
{#if !readonly}
|
||||
<h3>
|
||||
|
@ -137,9 +144,9 @@
|
|||
|
||||
{#if $missing.length > 0}
|
||||
{#if !readonly}
|
||||
<h3 class="m-0">
|
||||
<Tr t={t.missing.title} />
|
||||
</h3>
|
||||
<h3 class="m-0">
|
||||
<Tr t={t.missing.title} />
|
||||
</h3>
|
||||
|
||||
<Tr t={t.missing.intro} />
|
||||
{/if}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue