From 74e33baeda63f9a13f13197546c346675d50ffaf Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 22 Apr 2024 18:16:19 +0200 Subject: [PATCH] UX: improve text and handling of external data, fix #1911 --- langs/de.json | 1 - langs/en.json | 2 +- src/Logic/State/UserSettingsMetaTagging.ts | 48 ++++-------------- src/Logic/Web/LinkedDataLoader.ts | 3 ++ src/UI/Comparison/ComparisonTable.svelte | 59 +++++++++++++--------- src/UI/Comparison/ComparisonTool.svelte | 1 - src/UI/SpecialVisualizations.ts | 11 +--- 7 files changed, 50 insertions(+), 75 deletions(-) diff --git a/langs/de.json b/langs/de.json index daff4a11f..5a163c0f1 100644 --- a/langs/de.json +++ b/langs/de.json @@ -49,7 +49,6 @@ }, "external": { "allAreApplied": "Alle fehlenden, externen Werte wurden in OpenStreetMap kopiert", - "allIncluded": "Die externen Daten und die OpenStreetMap-Daten sind identisch", "apply": "Übernehmen", "applyAll": "Alle fehlenden Werte übernehmen", "conflicting": { diff --git a/langs/en.json b/langs/en.json index a3ff02353..1e686cf39 100644 --- a/langs/en.json +++ b/langs/en.json @@ -49,7 +49,7 @@ }, "external": { "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", "applyAll": "Apply all missing values", "conflicting": { diff --git a/src/Logic/State/UserSettingsMetaTagging.ts b/src/Logic/State/UserSettingsMetaTagging.ts index 6e568c5c3..33a5ae85b 100644 --- a/src/Logic/State/UserSettingsMetaTagging.ts +++ b/src/Logic/State/UserSettingsMetaTagging.ts @@ -1,42 +1,14 @@ import { Utils } from "../../Utils" /** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */ export class ThemeMetaTagging { - public static readonly themeName = "usersettings" + public static readonly themeName = "usersettings" - public metaTaggging_for_usersettings(feat: { properties: Record }) { - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () => - feat.properties._description - .match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/) - ?.at(1) - ) - Utils.AddLazyProperty( - 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" - } -} + public metaTaggging_for_usersettings(feat: {properties: Record}) { + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) ) + Utils.AddLazyProperty(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' + } +} \ No newline at end of file diff --git a/src/Logic/Web/LinkedDataLoader.ts b/src/Logic/Web/LinkedDataLoader.ts index 41c1e661d..1528b4323 100644 --- a/src/Logic/Web/LinkedDataLoader.ts +++ b/src/Logic/Web/LinkedDataLoader.ts @@ -194,6 +194,9 @@ export default class LinkedDataLoader { ) delete compacted["openingHours"] } + if(compacted["opening_hours"] === undefined){ + delete compacted["opening_hours"] + } if (compacted["geo"]) { compacted["geo"] = await LinkedDataLoader.geoToGeometry(compacted["geo"]) } diff --git a/src/UI/Comparison/ComparisonTable.svelte b/src/UI/Comparison/ComparisonTable.svelte index 176f219c4..ce15b7a40 100644 --- a/src/UI/Comparison/ComparisonTable.svelte +++ b/src/UI/Comparison/ComparisonTable.svelte @@ -1,6 +1,6 @@ - -{#if propertyKeysExternal.length === 0 && knownImages.size + unknownImages.length === 0} +{#if propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0} -{:else if unknownImages.length === 0 && missing.length === 0 && different.length === 0} +{:else if !hasDifferencesAtStart} + + + + +{:else if $unknownImages.length === 0 && $missing.length === 0 && $different.length === 0}
- - + +
{:else}
@@ -109,8 +118,8 @@ {#if !readonly} {/if} - {#if different.length > 0} - {#each different as key} + {#if $different.length > 0} + {#each $different as key}
0} + {#if $missing.length > 0} {#if currentStep === "init"} - {#each missing as key} + {#each $missing as key}
{/each} - {#if !readonly && missing.length > 1} + {#if !readonly && $missing.length > 1}
- {#if unknownImages.length > 0} + {#if $unknownImages.length > 0} {#if readonly}
- {#each unknownImages as image} + {#each $unknownImages as image}
{:else} - {#each unknownImages as image} + {#each $unknownImages as image} JSON.parse(data)) const sourceUrl: Store = url.mapD((url) => url.url) - const externalData: Store< - | { success: { content: any } } - | { - error: string - } - | undefined - | null - > = url.bindD(({ url, country }) => { + const externalData: Store<{ success: GeoJsonProperties } | { error: any }> = url.bindD(({ url, country }) => { if (url.startsWith("https://data.velopark.be/")) { return Stores.FromPromiseWithErr( (async () => {