diff --git a/assets/layers/usersettings/usersettings.json b/assets/layers/usersettings/usersettings.json index 7b8032710..1d0feb47c 100644 --- a/assets/layers/usersettings/usersettings.json +++ b/assets/layers/usersettings/usersettings.json @@ -901,6 +901,12 @@ } ] }, + { + "id": "pending_changes", + "render": { + "*": "{pending_changes()}" + } + }, { "id": "show_debug", "question": { diff --git a/langs/en.json b/langs/en.json index 01f9971b9..aa99604c7 100644 --- a/langs/en.json +++ b/langs/en.json @@ -213,6 +213,7 @@ "backgroundMap": "Select a background layer", "backgroundSwitch": "Switch background", "cancel": "Cancel", + "clearPendingChanges": "Clear pending changes", "confirm": "Confirm", "customThemeIntro": "These are previously visited user-generated themes.", "customThemeTitle": "Custom themes", diff --git a/src/Logic/Tags/TagUtils.ts b/src/Logic/Tags/TagUtils.ts index 670a8bd3e..0de2863fe 100644 --- a/src/Logic/Tags/TagUtils.ts +++ b/src/Logic/Tags/TagUtils.ts @@ -218,7 +218,7 @@ export class TagUtils { * * TagUtils.KVtoProperties([new Tag("a","b"), new Tag("c","d")] // => {a: "b", c: "d"} */ - static KVtoProperties(tags: Tag[]): Record { + static KVtoProperties(tags: {key: string, value: string}[]): Record { const properties: Record = {} for (const tag of tags) { properties[tag.key] = tag.value @@ -226,6 +226,14 @@ export class TagUtils { return properties } + static KVObjtoProperties(tags: {k: string, v: string}[]): Record { + const properties: Record = {} + for (const tag of tags) { + properties[tag.k] = tag.v + } + return properties + } + static changeAsProperties(kvs: { k: string; v: string }[]): Record { const tags: Record = {} for (const kv of kvs) { diff --git a/src/UI/BigComponents/PendingChangesIndicator.svelte b/src/UI/BigComponents/PendingChangesIndicator.svelte index a9b37435f..1c2749190 100644 --- a/src/UI/BigComponents/PendingChangesIndicator.svelte +++ b/src/UI/BigComponents/PendingChangesIndicator.svelte @@ -5,13 +5,15 @@ import Loading from "../Base/Loading.svelte" import Translations from "../i18n/Translations" import Tr from "../Base/Tr.svelte" + import { TagUtils } from "../../Logic/Tags/TagUtils" export let state: SpecialVisualizationState + export let compact: boolean = true const changes: Changes = state.changes const isUploading: Store = changes.isUploading - const pendingChangesCount: Store = changes.pendingChanges.map((ls) => ls.length) const errors = changes.errors + const pending = changes.pendingChanges
- {:else if $pendingChangesCount === 1} + {:else if $pending.length === 1} - {:else if $pendingChangesCount > 1} + {:else if $pending.length > 1} {/if} {#each $errors as error} {/each} + + {#if !compact && $pending.length > 0} + + +
    + + {#each $pending as pending} +
  • + + {#if pending.changes !== undefined} + Create {pending.type}/{pending.id} {JSON.stringify(TagUtils.KVObjtoProperties(pending.tags))} + {:else} + Modify {pending.type}/{pending.id} {JSON.stringify(pending.tags)} + {/if} + {#if pending.type === "way" && pending.changes?.nodes} + {pending.changes.nodes.join(" ")} + {/if} + +
  • + {/each} +
+ + {/if} + +
diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index bdfad68b7..d7b05273b 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -95,6 +95,7 @@ import NothingKnown from "./Popup/NothingKnown.svelte" import { CombinedFetcher } from "../Logic/Web/NearbyImagesSearch" import { And } from "../Logic/Tags/And" import CloseNoteButton from "./Popup/Notes/CloseNoteButton.svelte" +import PendingChangesIndicator from "./BigComponents/PendingChangesIndicator.svelte" class NearbyImageVis implements SpecialVisualization { // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests @@ -2003,6 +2004,14 @@ export default class SpecialVisualizations { }) return new VariableUiElement(translation) } + }, + { + funcName:"pending_changes", + docs: "A module showing the pending changes, with the option to clear the pending changes", + args:[], + constr(state: SpecialVisualizationState, tagSource: UIEventSource>, argument: string[], feature: Feature, layer: LayerConfig): BaseUIElement { + return new SvelteUIElement(PendingChangesIndicator, {state, compact: false}) + } } ]