diff --git a/assets/layers/maproulette/maproulette.json b/assets/layers/maproulette/maproulette.json index 9c5a24c713..a536c73e7c 100644 --- a/assets/layers/maproulette/maproulette.json +++ b/assets/layers/maproulette/maproulette.json @@ -238,7 +238,7 @@ "cs": "Označit jako příliš těžké" }, "status": "6", - "image": "not_found" + "image": "./assets/svg/not_found.svg" } } } diff --git a/src/UI/Map/Icon.svelte b/src/UI/Map/Icon.svelte index dc8783494f..d39f534444 100644 --- a/src/UI/Map/Icon.svelte +++ b/src/UI/Map/Icon.svelte @@ -24,6 +24,9 @@ import Gps_arrow from "../../assets/svg/Gps_arrow.svelte"; import { HeartIcon } from "@babeard/svelte-heroicons/solid"; import { HeartIcon as HeartOutlineIcon } from "@babeard/svelte-heroicons/outline"; + import Confirm from "../../assets/svg/Confirm.svelte"; + import Not_found from "../../assets/svg/Not_found.svelte"; + import { twMerge } from "tailwind-merge"; /** * Renders a single icon. @@ -32,71 +35,75 @@ */ export let icon: string | undefined; - export let color: string | undefined = undefined - export let clss: string | undefined = undefined + export let color: string | undefined = undefined; + export let clss: string | undefined = undefined; {#if icon} - {#if icon === "pin"} - - {:else if icon === "square"} - - {:else if icon === "circle"} - - {:else if icon === "checkmark"} - - {:else if icon === "clock"} - - {:else if icon === "close"} - - {:else if icon === "crosshair"} - - {:else if icon === "help"} - - {:else if icon === "home"} - - {:else if icon === "invalid"} - - {:else if icon === "location"} - - {:else if icon === "location_empty"} - - {:else if icon === "location_locked"} - - {:else if icon === "note"} - - {:else if icon === "resolved"} - - {:else if icon === "ring"} - - {:else if icon === "scissors"} - - {:else if icon === "teardrop"} - - {:else if icon === "teardrop_with_hole_green"} - - {:else if icon === "triangle"} - - {:else if icon === "brick_wall_square"} - - {:else if icon === "brick_wall_round"} - - {:else if icon === "gps_arrow"} - - {:else if icon === "checkmark"} - - {:else if icon === "help"} - - {:else if icon === "close"} - - {:else if icon === "invalid"} - - {:else if icon === "heart"} - - {:else if icon === "heart_outline"} - - {:else} - - {/if} + {#if icon === "pin"} + + {:else if icon === "square"} + + {:else if icon === "circle"} + + {:else if icon === "checkmark"} + + {:else if icon === "clock"} + + {:else if icon === "close"} + + {:else if icon === "crosshair"} + + {:else if icon === "help"} + + {:else if icon === "home"} + + {:else if icon === "invalid"} + + {:else if icon === "location"} + + {:else if icon === "location_empty"} + + {:else if icon === "location_locked"} + + {:else if icon === "note"} + + {:else if icon === "resolved"} + + {:else if icon === "ring"} + + {:else if icon === "scissors"} + + {:else if icon === "teardrop"} + + {:else if icon === "teardrop_with_hole_green"} + + {:else if icon === "triangle"} + + {:else if icon === "brick_wall_square"} + + {:else if icon === "brick_wall_round"} + + {:else if icon === "gps_arrow"} + + {:else if icon === "checkmark"} + + {:else if icon === "help"} + + {:else if icon === "close"} + + {:else if icon === "invalid"} + + {:else if icon === "heart"} + + {:else if icon === "heart_outline"} + + {:else if icon === "confirm"} + + {:else if icon === "not_found"} + + {:else} + + {/if} {/if} diff --git a/src/UI/MapRoulette/MaprouletteSetStatus.svelte b/src/UI/MapRoulette/MaprouletteSetStatus.svelte new file mode 100644 index 0000000000..c2071b59de --- /dev/null +++ b/src/UI/MapRoulette/MaprouletteSetStatus.svelte @@ -0,0 +1,73 @@ + + +{#if failed} +
+ ERROR - could not close the MapRoulette task +
+{:else if applying} + + + +{:else if $status === Maproulette.STATUS_OPEN} + +{:else} + {message_closed} +{/if} diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index 0439a3c15a..9170b0947f 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -83,6 +83,7 @@ import NearbyImages from "./Image/NearbyImages.svelte" import NearbyImagesCollapsed from "./Image/NearbyImagesCollapsed.svelte" import { svelte } from "@sveltejs/vite-plugin-svelte" import MoveWizard from "./Popup/MoveWizard.svelte" +import MaprouletteSetStatus from "./MapRoulette/MaprouletteSetStatus.svelte" class NearbyImageVis implements SpecialVisualization { // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests @@ -1141,73 +1142,22 @@ export default class SpecialVisualizations { }, ], constr: (state, tagsSource, args) => { - let [message, image, message_closed, status, maproulette_id_key] = args + let [message, image, message_closed, statusToSet, maproulette_id_key] = args if (image === "") { image = "confirm" } if (maproulette_id_key === "" || maproulette_id_key === undefined) { maproulette_id_key = "mr_taskId" } - const failed = new UIEventSource(false) - - const closeButton = new SubtleButton(image, message).OnClickWithLoading( - Translations.t.general.loading, - async () => { - const maproulette_id = - tagsSource.data[maproulette_id_key] ?? - tagsSource.data.mr_taskId ?? - tagsSource.data.id - try { - await Maproulette.singleton.closeTask( - Number(maproulette_id), - Number(status), - { - tags: `MapComplete MapComplete:${state.layout.id}`, - } - ) - tagsSource.data["mr_taskStatus"] = - Maproulette.STATUS_MEANING[Number(status)] - tagsSource.data.status = status - tagsSource.ping() - } catch (e) { - console.error(e) - failed.setData(true) - } - } - ) - - let message_closed_element = undefined - if (message_closed !== undefined && message_closed !== "") { - message_closed_element = new FixedUiElement(message_closed) - } - - return new VariableUiElement( - tagsSource - .map((tgs) => { - if (tgs["status"]) { - return tgs["status"] - } - const code = tgs["mr_taskStatus"] - console.log("Code is", code, Maproulette.codeToIndex(code)) - return Maproulette.codeToIndex(code) - }) - .map(Number) - .map( - (status) => { - console.log("Close MR button: status is", status) - if (failed.data) { - return new FixedUiElement( - "ERROR - could not close the MapRoulette task" - ).SetClass("block alert") - } - if (status === Maproulette.STATUS_OPEN) { - return closeButton - } - return message_closed_element ?? "Closed!" - }, - [failed] - ) - ) + return new SvelteUIElement(MaprouletteSetStatus, { + state, + tags: tagsSource, + message, + image, + message_closed, + statusToSet, + maproulette_id_key, + }) }, }, {