MapComplete/src/UI/BigComponents/PendingChangesIndicator.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1.2 KiB
Svelte
Raw Normal View History

2023-10-16 13:38:11 +02:00
<script lang="ts">
2023-10-16 14:27:05 +02:00
import type { SpecialVisualizationState } from "../SpecialVisualization"
import { Store } from "../../Logic/UIEventSource"
import { Changes } from "../../Logic/Osm/Changes"
import Loading from "../Base/Loading.svelte"
import Translations from "../i18n/Translations"
import Tr from "../Base/Tr.svelte"
2023-10-16 13:38:11 +02:00
2023-10-16 14:27:05 +02:00
export let state: SpecialVisualizationState
2023-10-16 13:38:11 +02:00
2023-10-16 14:27:05 +02:00
const changes: Changes = state.changes
const isUploading: Store<boolean> = changes.isUploading
const pendingChangesCount: Store<number> = changes.pendingChanges.map((ls) => ls.length)
const errors = changes.errors
2023-10-16 13:38:11 +02:00
</script>
2023-10-16 14:27:05 +02:00
<div
class="pointer-events-auto flex flex-col"
on:click={() => changes.flushChanges("Pending changes indicator clicked")}
>
2023-10-16 13:38:11 +02:00
{#if $isUploading}
<Loading>
<Tr cls="thx" t={Translations.t.general.uploadingChanges} />
</Loading>
{:else if $pendingChangesCount === 1}
<Tr cls="alert" t={Translations.t.general.uploadPendingSingle} />
{:else if $pendingChangesCount > 1}
2023-10-16 14:27:05 +02:00
<Tr
cls="alert"
t={Translations.t.general.uploadPending.Subs({ count: $pendingChangesCount })}
/>
2023-10-16 13:38:11 +02:00
{/if}
{#each $errors as error}
2023-10-16 14:27:05 +02:00
<Tr cls="alert" t={Translations.t.general.uploadError.Subs({ error })} />
2023-10-16 13:38:11 +02:00
{/each}
</div>