forked from MapComplete/MapComplete
UX: improve text and handling of external data, fix #1911
This commit is contained in:
parent
8368d86c51
commit
74e33baeda
7 changed files with 50 additions and 75 deletions
|
@ -49,7 +49,6 @@
|
||||||
},
|
},
|
||||||
"external": {
|
"external": {
|
||||||
"allAreApplied": "Alle fehlenden, externen Werte wurden in OpenStreetMap kopiert",
|
"allAreApplied": "Alle fehlenden, externen Werte wurden in OpenStreetMap kopiert",
|
||||||
"allIncluded": "Die externen Daten und die OpenStreetMap-Daten sind identisch",
|
|
||||||
"apply": "Übernehmen",
|
"apply": "Übernehmen",
|
||||||
"applyAll": "Alle fehlenden Werte übernehmen",
|
"applyAll": "Alle fehlenden Werte übernehmen",
|
||||||
"conflicting": {
|
"conflicting": {
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
},
|
},
|
||||||
"external": {
|
"external": {
|
||||||
"allAreApplied": "All missing, external values have been copied into OpenStreetMap",
|
"allAreApplied": "All missing, external values have been copied into OpenStreetMap",
|
||||||
"allIncluded": "The external data and OpenStreetMap-data are the same",
|
"allIncluded": "Data loaded from {source} is contained in OpenStreetMap",
|
||||||
"apply": "Apply",
|
"apply": "Apply",
|
||||||
"applyAll": "Apply all missing values",
|
"applyAll": "Apply all missing values",
|
||||||
"conflicting": {
|
"conflicting": {
|
||||||
|
|
|
@ -1,42 +1,14 @@
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
|
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
|
||||||
export class ThemeMetaTagging {
|
export class ThemeMetaTagging {
|
||||||
public static readonly themeName = "usersettings"
|
public static readonly themeName = "usersettings"
|
||||||
|
|
||||||
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
|
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
|
||||||
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
|
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
|
||||||
feat.properties._description
|
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/</g,'<')?.replace(/>/g,'>') ?? '' )
|
||||||
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
|
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
|
||||||
?.at(1)
|
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
|
||||||
)
|
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
|
||||||
Utils.AddLazyProperty(
|
feat.properties['__current_backgroun'] = 'initial_value'
|
||||||
feat.properties,
|
}
|
||||||
"_d",
|
}
|
||||||
() => feat.properties._description?.replace(/</g, "<")?.replace(/>/g, ">") ?? ""
|
|
||||||
)
|
|
||||||
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
|
|
||||||
((feat) => {
|
|
||||||
const e = document.createElement("div")
|
|
||||||
e.innerHTML = feat.properties._d
|
|
||||||
return Array.from(e.getElementsByTagName("a")).filter(
|
|
||||||
(a) => a.href.match(/mastodon|en.osm.town/) !== null
|
|
||||||
)[0]?.href
|
|
||||||
})(feat)
|
|
||||||
)
|
|
||||||
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
|
|
||||||
((feat) => {
|
|
||||||
const e = document.createElement("div")
|
|
||||||
e.innerHTML = feat.properties._d
|
|
||||||
return Array.from(e.getElementsByTagName("a")).filter(
|
|
||||||
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
|
|
||||||
)[0]?.href
|
|
||||||
})(feat)
|
|
||||||
)
|
|
||||||
Utils.AddLazyProperty(
|
|
||||||
feat.properties,
|
|
||||||
"_mastodon_candidate",
|
|
||||||
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
|
|
||||||
)
|
|
||||||
feat.properties["__current_backgroun"] = "initial_value"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -194,6 +194,9 @@ export default class LinkedDataLoader {
|
||||||
)
|
)
|
||||||
delete compacted["openingHours"]
|
delete compacted["openingHours"]
|
||||||
}
|
}
|
||||||
|
if(compacted["opening_hours"] === undefined){
|
||||||
|
delete compacted["opening_hours"]
|
||||||
|
}
|
||||||
if (compacted["geo"]) {
|
if (compacted["geo"]) {
|
||||||
compacted["geo"] = <any>await LinkedDataLoader.geoToGeometry(compacted["geo"])
|
compacted["geo"] = <any>await LinkedDataLoader.geoToGeometry(compacted["geo"])
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import LinkableImage from "../Image/LinkableImage.svelte"
|
import LinkableImage from "../Image/LinkableImage.svelte"
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import type { OsmTags } from "../../Models/OsmFeature"
|
import type { OsmTags } from "../../Models/OsmFeature"
|
||||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||||
import type { Feature } from "geojson"
|
import type { Feature } from "geojson"
|
||||||
|
@ -15,8 +15,10 @@
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import Tr from "../Base/Tr.svelte"
|
import Tr from "../Base/Tr.svelte"
|
||||||
|
|
||||||
export let osmProperties: Record<string, string>
|
|
||||||
export let externalProperties: Record<string, string>
|
export let externalProperties: Record<string, string>
|
||||||
|
delete externalProperties["@context"]
|
||||||
|
console.log("External properties are", externalProperties)
|
||||||
export let sourceUrl: string
|
export let sourceUrl: string
|
||||||
|
|
||||||
export let tags: UIEventSource<OsmTags>
|
export let tags: UIEventSource<OsmTags>
|
||||||
|
@ -31,25 +33,26 @@
|
||||||
let externalKeys: string[] = Object.keys(externalProperties).sort()
|
let externalKeys: string[] = Object.keys(externalProperties).sort()
|
||||||
|
|
||||||
const imageKeyRegex = /image|image:[0-9]+/
|
const imageKeyRegex = /image|image:[0-9]+/
|
||||||
let knownImages = new Set(
|
let knownImages: Store<Set<string>> = tags.map(osmProperties => new Set(
|
||||||
Object.keys(osmProperties)
|
Object.keys(osmProperties)
|
||||||
.filter((k) => k.match(imageKeyRegex))
|
.filter((k) => k.match(imageKeyRegex))
|
||||||
.map((k) => osmProperties[k])
|
.map((k) => osmProperties[k])
|
||||||
)
|
))
|
||||||
let unknownImages = externalKeys
|
let unknownImages: Store<string[]> = knownImages.map(images => externalKeys
|
||||||
.filter((k) => k.match(imageKeyRegex))
|
.filter((k) => k.match(imageKeyRegex))
|
||||||
.map((k) => externalProperties[k])
|
.map((k) => externalProperties[k])
|
||||||
.filter((i) => !knownImages.has(i))
|
.filter((i) => !images.has(i)))
|
||||||
|
|
||||||
|
|
||||||
let propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
|
let propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
|
||||||
let missing = propertyKeysExternal.filter((k) => {
|
let missing: Store<string[]> = tags.map(osmProperties => propertyKeysExternal.filter((k) => {
|
||||||
if (k.startsWith("_")) {
|
if (k.startsWith("_")) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return osmProperties[k] === undefined && typeof externalProperties[k] === "string"
|
return osmProperties[k] === undefined && typeof externalProperties[k] === "string"
|
||||||
})
|
}))
|
||||||
// let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
// let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
||||||
let different = propertyKeysExternal.filter((key) => {
|
let different: Store<string[]> = tags.map(osmProperties => propertyKeysExternal.filter((key) => {
|
||||||
if (key.startsWith("_")) {
|
if (key.startsWith("_")) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -72,29 +75,35 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
}))
|
||||||
|
|
||||||
|
let hasDifferencesAtStart = (different.data.length + missing.data.length + unknownImages.data.length) > 0
|
||||||
|
|
||||||
let currentStep: "init" | "applying_all" | "all_applied" = "init"
|
let currentStep: "init" | "applying_all" | "all_applied" = "init"
|
||||||
let applyAllHovered = false
|
let applyAllHovered = false
|
||||||
|
|
||||||
async function applyAllMissing() {
|
async function applyAllMissing() {
|
||||||
currentStep = "applying_all"
|
currentStep = "applying_all"
|
||||||
const tagsToApply = missing.map((k) => new Tag(k, externalProperties[k]))
|
const tagsToApply = missing.data.map((k) => new Tag(k, externalProperties[k]))
|
||||||
const change = new ChangeTagAction(tags.data.id, new And(tagsToApply), tags.data, {
|
const change = new ChangeTagAction(tags.data.id, new And(tagsToApply), tags.data, {
|
||||||
theme: state.layout.id,
|
theme: state.layout.id,
|
||||||
changeType: "import",
|
changeType: "import"
|
||||||
})
|
})
|
||||||
await state.changes.applyChanges(await change.CreateChangeDescriptions())
|
await state.changes.applyChanges(await change.CreateChangeDescriptions())
|
||||||
currentStep = "all_applied"
|
currentStep = "all_applied"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
{#if propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0}
|
||||||
{#if propertyKeysExternal.length === 0 && knownImages.size + unknownImages.length === 0}
|
|
||||||
<Tr cls="subtle" t={t.noDataLoaded} />
|
<Tr cls="subtle" t={t.noDataLoaded} />
|
||||||
{:else if unknownImages.length === 0 && missing.length === 0 && different.length === 0}
|
{:else if !hasDifferencesAtStart}
|
||||||
|
<span class="subtle text-sm">
|
||||||
|
<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">
|
<div class="thanks m-0 flex items-center gap-x-2 px-2">
|
||||||
<Party class="h-8 w-8" />
|
<Party class="h-8 w-8 shrink-0" />
|
||||||
<Tr t={t.allIncluded} />
|
<Tr t={t.allIncluded.Subs({source: sourceUrl})} />
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="low-interaction border-interactive p-1">
|
<div class="low-interaction border-interactive p-1">
|
||||||
|
@ -109,8 +118,8 @@
|
||||||
{#if !readonly}
|
{#if !readonly}
|
||||||
<Tr t={t.conflicting.intro} />
|
<Tr t={t.conflicting.intro} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if different.length > 0}
|
{#if $different.length > 0}
|
||||||
{#each different as key}
|
{#each $different as key}
|
||||||
<div class="mx-2 rounded-2xl">
|
<div class="mx-2 rounded-2xl">
|
||||||
<ComparisonAction
|
<ComparisonAction
|
||||||
{key}
|
{key}
|
||||||
|
@ -125,9 +134,9 @@
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if missing.length > 0}
|
{#if $missing.length > 0}
|
||||||
{#if currentStep === "init"}
|
{#if currentStep === "init"}
|
||||||
{#each missing as key}
|
{#each $missing as key}
|
||||||
<div class:glowing-shadow={applyAllHovered} class="mx-2 rounded-2xl">
|
<div class:glowing-shadow={applyAllHovered} class="mx-2 rounded-2xl">
|
||||||
<ComparisonAction
|
<ComparisonAction
|
||||||
{key}
|
{key}
|
||||||
|
@ -140,7 +149,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{#if !readonly && missing.length > 1}
|
{#if !readonly && $missing.length > 1}
|
||||||
<button
|
<button
|
||||||
on:click={() => applyAllMissing()}
|
on:click={() => applyAllMissing()}
|
||||||
on:mouseover={() => (applyAllHovered = true)}
|
on:mouseover={() => (applyAllHovered = true)}
|
||||||
|
@ -161,11 +170,11 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if unknownImages.length > 0}
|
{#if $unknownImages.length > 0}
|
||||||
{#if readonly}
|
{#if readonly}
|
||||||
<div class="w-full overflow-x-auto">
|
<div class="w-full overflow-x-auto">
|
||||||
<div class="flex h-32 w-max gap-x-2">
|
<div class="flex h-32 w-max gap-x-2">
|
||||||
{#each unknownImages as image}
|
{#each $unknownImages as image}
|
||||||
<AttributedImage
|
<AttributedImage
|
||||||
imgClass="h-32 w-max shrink-0"
|
imgClass="h-32 w-max shrink-0"
|
||||||
image={{ url: image }}
|
image={{ url: image }}
|
||||||
|
@ -175,7 +184,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#each unknownImages as image}
|
{#each $unknownImages as image}
|
||||||
<LinkableImage
|
<LinkableImage
|
||||||
{tags}
|
{tags}
|
||||||
{state}
|
{state}
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
{:else if $externalData["success"] !== undefined}
|
{:else if $externalData["success"] !== undefined}
|
||||||
<ComparisonTable
|
<ComparisonTable
|
||||||
externalProperties={$externalData["success"]}
|
externalProperties={$externalData["success"]}
|
||||||
osmProperties={$tags}
|
|
||||||
{state}
|
{state}
|
||||||
{feature}
|
{feature}
|
||||||
{layer}
|
{layer}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import FeatureReviews from "../Logic/Web/MangroveReviews"
|
||||||
import Maproulette from "../Logic/Maproulette"
|
import Maproulette from "../Logic/Maproulette"
|
||||||
import SvelteUIElement from "./Base/SvelteUIElement"
|
import SvelteUIElement from "./Base/SvelteUIElement"
|
||||||
import { BBoxFeatureSourceForLayer } from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource"
|
import { BBoxFeatureSourceForLayer } from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource"
|
||||||
import { Feature } from "geojson"
|
import { Feature, GeoJsonProperties } from "geojson"
|
||||||
import { GeoOperations } from "../Logic/GeoOperations"
|
import { GeoOperations } from "../Logic/GeoOperations"
|
||||||
import CreateNewNote from "./Popup/Notes/CreateNewNote.svelte"
|
import CreateNewNote from "./Popup/Notes/CreateNewNote.svelte"
|
||||||
import AddNewPoint from "./Popup/AddNewPoint/AddNewPoint.svelte"
|
import AddNewPoint from "./Popup/AddNewPoint/AddNewPoint.svelte"
|
||||||
|
@ -1794,14 +1794,7 @@ export default class SpecialVisualizations {
|
||||||
})
|
})
|
||||||
.mapD((data) => JSON.parse(data))
|
.mapD((data) => JSON.parse(data))
|
||||||
const sourceUrl: Store<string | undefined> = url.mapD((url) => url.url)
|
const sourceUrl: Store<string | undefined> = url.mapD((url) => url.url)
|
||||||
const externalData: Store<
|
const externalData: Store<{ success: GeoJsonProperties } | { error: any }> = url.bindD(({ url, country }) => {
|
||||||
| { success: { content: any } }
|
|
||||||
| {
|
|
||||||
error: string
|
|
||||||
}
|
|
||||||
| undefined
|
|
||||||
| null
|
|
||||||
> = url.bindD(({ url, country }) => {
|
|
||||||
if (url.startsWith("https://data.velopark.be/")) {
|
if (url.startsWith("https://data.velopark.be/")) {
|
||||||
return Stores.FromPromiseWithErr(
|
return Stores.FromPromiseWithErr(
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue