SpecialVis: add readonly mode to ComparisonTable

This commit is contained in:
Pieter Vander Vennet 2024-01-16 04:21:11 +01:00
parent 915cad2253
commit b26ffaaf22
3 changed files with 60 additions and 28 deletions

View file

@ -16,6 +16,8 @@
export let feature: Feature export let feature: Feature
export let layer: LayerConfig export let layer: LayerConfig
export let readonly = false
let currentStep: "init" | "applying" | "done" = "init" let currentStep: "init" | "applying" | "done" = "init"
/** /**
@ -49,17 +51,19 @@
{externalProperties[key]} {externalProperties[key]}
{/if} {/if}
</td> </td>
<td> {#if !readonly}
{#if currentStep === "init"} <td>
<button class="small" on:click={() => apply(key)}> {#if currentStep === "init"}
Apply <button class="small" on:click={() => apply(key)}>
</button> Apply
{:else if currentStep === "applying"} </button>
<Loading /> {:else if currentStep === "applying"}
{:else if currentStep === "done"} <Loading />
<div class="thanks">Done</div> {:else if currentStep === "done"}
{:else } <div class="thanks">Done</div>
<div class="alert">Error</div> {:else }
{/if} <div class="alert">Error</div>
</td> {/if}
</td>
{/if}
</tr> </tr>

View file

@ -12,6 +12,7 @@
import { Tag } from "../../Logic/Tags/Tag" import { Tag } from "../../Logic/Tags/Tag"
import { And } from "../../Logic/Tags/And" import { And } from "../../Logic/Tags/And"
import Loading from "../Base/Loading.svelte" import Loading from "../Base/Loading.svelte"
import AttributedImage from "../Image/AttributedImage.svelte"
export let osmProperties: Record<string, string> export let osmProperties: Record<string, string>
export let externalProperties: Record<string, string> export let externalProperties: Record<string, string>
@ -21,6 +22,8 @@
export let feature: Feature export let feature: Feature
export let layer: LayerConfig export let layer: LayerConfig
export let readonly = false
let externalKeys: string[] = (Object.keys(externalProperties)) let externalKeys: string[] = (Object.keys(externalProperties))
.sort() .sort()
@ -59,12 +62,23 @@
{#if different.length > 0} {#if different.length > 0}
<h3>Conflicting items</h3> <h3>Conflicting items</h3>
{JSON.stringify(different)} <table>
<tr>
<th>Key</th>
<th>OSM</th>
<th>External</th>
</tr>
{#each different as key}
<tr>
<td>{key}</td>
<td>{osmProperties[key]}</td>
<td>{externalProperties[key]}</td>
</tr>
{/each}
</table>
{/if} {/if}
{#if missing.length > 0} {#if missing.length > 0}
<h3>Missing items</h3>
{#if currentStep === "init"} {#if currentStep === "init"}
<table class="w-full"> <table class="w-full">
<tr> <tr>
@ -73,11 +87,13 @@
</tr> </tr>
{#each missing as key} {#each missing as key}
<ComparisonAction {key} {state} {tags} {externalProperties} {layer} {feature} /> <ComparisonAction {key} {state} {tags} {externalProperties} {layer} {feature} {readonly} />
{/each} {/each}
</table> </table>
<button on:click={() => applyAllMissing()}>Apply all missing values</button> {#if !readonly}
<button on:click={() => applyAllMissing()}>Apply all missing values</button>
{/if}
{:else if currentStep === "applying_all"} {:else if currentStep === "applying_all"}
<Loading>Applying all missing values</Loading> <Loading>Applying all missing values</Loading>
{:else if currentStep === "all_applied"} {:else if currentStep === "all_applied"}
@ -96,12 +112,22 @@
{/if} {/if}
{#if unknownImages.length > 0} {#if unknownImages.length > 0}
<h3>Missing pictures</h3> {#if readonly}
{#each unknownImages as image} <div class="w-full overflow-x-auto">
<LinkableImage
{tags} <div class="flex w-max gap-x-2 h-32">
{state} {#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}
<LinkableImage
{tags}
{state}
image={{
pictureUrl: image, pictureUrl: image,
provider: "Velopark", provider: "Velopark",
thumbUrl: image, thumbUrl: image,
@ -109,9 +135,10 @@
coordinates: undefined, coordinates: undefined,
osmTags : {image} osmTags : {image}
} } } }
{feature} {feature}
{layer} /> {layer} />
{/each} {/each}
{/if}
{/if} {/if}

View file

@ -19,6 +19,7 @@ export let state: SpecialVisualizationState
export let tags: UIEventSource<OsmTags> export let tags: UIEventSource<OsmTags>
export let layer: LayerConfig export let layer: LayerConfig
export let feature: Feature export let feature: Feature
export let readonly = false
let data: any = undefined let data: any = undefined
let error: any = undefined let error: any = undefined
@ -58,5 +59,5 @@ onMount(async () => {
Loading {$tags[url]} Loading {$tags[url]}
</Loading> </Loading>
{:else if data.properties !== undefined} {:else if data.properties !== undefined}
<ComparisonTable externalProperties={data.properties} osmProperties={$tags} {state} {feature} {layer} {tags} /> <ComparisonTable externalProperties={data.properties} osmProperties={$tags} {state} {feature} {layer} {tags} {readonly} />
{/if} {/if}