Chore: housekeeping

This commit is contained in:
Pieter Vander Vennet 2024-06-20 04:21:29 +02:00
parent 8178c5607b
commit cd0d275965
73 changed files with 2105 additions and 2219 deletions

View file

@ -67,7 +67,7 @@
<div>
<div class:interactive={!readonly} class="flex flex-col items-end py-1 px-2">
<div class="flex flex-col w-full">
<div class="flex w-full flex-col">
{#if renderingExternal}
<TagRenderingAnswer
tags={new UIEventSource(mockPropertiesExternal)}

View file

@ -11,7 +11,6 @@ export class ComparisonState {
public readonly knownImages: Store<Set<string>>
constructor(tags: UIEventSource<OsmTags>, externalProperties: Record<string, string>) {
externalProperties = { ...externalProperties }
delete externalProperties["@context"]
@ -74,7 +73,7 @@ export class ComparisonState {
)
this.hasDifferencesAtStart =
this. different.data.length + this.missing.data.length + this.unknownImages.data.length > 0
this.different.data.length + this.missing.data.length + this.unknownImages.data.length >
0
}
}

View file

@ -27,11 +27,11 @@
export let readonly = false
export let comparisonState : ComparisonState
export let comparisonState: ComparisonState
let missing = comparisonState.missing
let unknownImages = comparisonState.unknownImages
let knownImages = comparisonState.knownImages
let different =comparisonState.different
let different = comparisonState.different
const t = Translations.t.external
@ -50,27 +50,50 @@
}
</script>
{#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 })} />
</div>
{:else}
{#if !readonly}
<Tr t={t.loadedFrom.Subs({ url: sourceUrl, source: sourceUrl })} />
{#if !readonly}
<Tr t={t.loadedFrom.Subs({ url: sourceUrl, source: sourceUrl })} />
{/if}
<div class="flex flex-col" class:gap-y-8={!readonly}>
{#if $different.length > 0}
{#if !readonly}
<h3>
<Tr t={t.conflicting.title} />
</h3>
<Tr t={t.conflicting.intro} />
{/if}
{#each $different as key (key)}
<div class="mx-2 rounded-2xl">
<ComparisonAction
{key}
{state}
{tags}
{externalProperties}
{layer}
{feature}
{readonly}
/>
</div>
{/each}
{/if}
<div class="flex flex-col" class:gap-y-8={!readonly}>
{#if $different.length > 0}
{#if !readonly}
<h3>
<Tr t={t.conflicting.title} />
</h3>
<Tr t={t.conflicting.intro} />
{/if}
{#each $different as key (key)}
<div class="mx-2 rounded-2xl">
{#if $missing.length > 0}
{#if !readonly}
<h3 class="m-0">
<Tr t={t.missing.title} />
</h3>
<Tr t={t.missing.intro} />
{/if}
{#if currentStep === "init"}
{#each $missing as key (key)}
<div class:focus={applyAllHovered} class="mx-2 rounded-2xl">
<ComparisonAction
{key}
{state}
@ -82,86 +105,66 @@
/>
</div>
{/each}
{/if}
{#if $missing.length > 0}
{#if !readonly}
<h3 class="m-0">
<Tr t={t.missing.title} />
</h3>
<Tr t={t.missing.intro} />
{#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)}
>
<Tr t={t.applyAll} />
</button>
{/if}
{#if currentStep === "init"}
{#each $missing as key (key)}
<div class:focus={applyAllHovered} class="mx-2 rounded-2xl">
<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)}
>
<Tr t={t.applyAll} />
</button>
{/if}
{:else if currentStep === "applying_all"}
<Loading />
{:else if currentStep === "all_applied"}
<div class="thanks">
<Tr t={t.allAreApplied} />
</div>
{/if}
{/if}
</div>
{#if $unknownImages.length > 0}
{#if readonly}
<div class="w-full overflow-x-auto">
<div class="flex h-32 w-max gap-x-2">
{#each $unknownImages as image (image)}
<AttributedImage
imgClass="h-32 w-max shrink-0"
image={{ url: image }}
previewedImage={state.previewedImage}
/>
{/each}
</div>
{:else if currentStep === "applying_all"}
<Loading />
{:else if currentStep === "all_applied"}
<div class="thanks">
<Tr t={t.allAreApplied} />
</div>
{:else}
{#each $unknownImages as image (image)}
<LinkableImage
{tags}
{state}
image={{
pictureUrl: image,
provider: "Velopark",
thumbUrl: image,
details: undefined,
coordinates: undefined,
osmTags: { image },
}}
{feature}
{layer}
/>
{/each}
{/if}
{/if}
{#if externalProperties["_last_edit_timestamp"] !== undefined}
<span class="subtle text-sm flex flex-end justify-end mt-2 mr-4">
<Tr t={t.lastModified.Subs({date: new Date(externalProperties["_last_edit_timestamp"]).toLocaleString() })}/>
</span>
</div>
{#if $unknownImages.length > 0}
{#if readonly}
<div class="w-full overflow-x-auto">
<div class="flex h-32 w-max gap-x-2">
{#each $unknownImages as image (image)}
<AttributedImage
imgClass="h-32 w-max shrink-0"
image={{ url: image }}
previewedImage={state.previewedImage}
/>
{/each}
</div>
</div>
{:else}
{#each $unknownImages as image (image)}
<LinkableImage
{tags}
{state}
image={{
pictureUrl: image,
provider: "Velopark",
thumbUrl: image,
details: undefined,
coordinates: undefined,
osmTags: { image },
}}
{feature}
{layer}
/>
{/each}
{/if}
{/if}
{#if externalProperties["_last_edit_timestamp"] !== undefined}
<span class="subtle flex-end mt-2 mr-4 flex justify-end text-sm">
<Tr
t={t.lastModified.Subs({
date: new Date(externalProperties["_last_edit_timestamp"]).toLocaleString(),
})}
/>
</span>
{/if}
{/if}

View file

@ -32,17 +32,16 @@
export let collapsed: boolean
const t = Translations.t.external
let comparisonState: Store<ComparisonState | undefined> = externalData.mapD(external => {
let comparisonState: Store<ComparisonState | undefined> = externalData.mapD((external) => {
if (external["success"]) {
return new ComparisonState(tags, external["success"])
}
return undefined
})
let unknownImages = comparisonState.bindD(ct => ct.unknownImages)
let knownImages = comparisonState.bindD(ct => ct.knownImages)
let propertyKeysExternal = comparisonState.mapD(ct => ct.propertyKeysExternal)
let hasDifferencesAtStart = comparisonState.mapD(ct => ct.hasDifferencesAtStart)
let unknownImages = comparisonState.bindD((ct) => ct.unknownImages)
let knownImages = comparisonState.bindD((ct) => ct.knownImages)
let propertyKeysExternal = comparisonState.mapD((ct) => ct.propertyKeysExternal)
let hasDifferencesAtStart = comparisonState.mapD((ct) => ct.hasDifferencesAtStart)
</script>
{#if !$sourceUrl}
@ -50,7 +49,7 @@
{:else if $externalData === undefined}
<Loading />
{:else if $externalData["error"] !== undefined}
<div class="subtle italic low-interaction p-2 px-4 rounded">
<div class="subtle low-interaction rounded p-2 px-4 italic">
<Tr t={Translations.t.external.error} />
</div>
{:else if $propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0}
@ -62,7 +61,7 @@
{:else if $comparisonState !== undefined}
<AccordionSingle expanded={!collapsed}>
<span slot="header" class="flex">
<GlobeAlt class="w-6 h-6" />
<GlobeAlt class="h-6 w-6" />
<Tr t={Translations.t.external.title} />
</span>
<ComparisonTable