forked from MapComplete/MapComplete
Refactoring: move specialVisulations into groups
This commit is contained in:
parent
644445248c
commit
b59524733c
13 changed files with 894 additions and 900 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import type { Feature, Point } from "geojson"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import LoginToggle from "../Base/LoginToggle.svelte"
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
import Scissors from "@babeard/svelte-heroicons/solid/Scissors"
|
||||
|
||||
export let state: SpecialVisualizationState
|
||||
export let id: WayId
|
||||
export let id: Store<WayId>
|
||||
const t = Translations.t.split
|
||||
let snapTolerance = 5 // meter
|
||||
let step:
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
async function downloadWay() {
|
||||
step = "loading_way"
|
||||
const dloaded = await state.osmObjectDownloader.DownloadObjectAsync(id)
|
||||
const dloaded = await state.osmObjectDownloader.DownloadObjectAsync(id.data)
|
||||
if (dloaded === "deleted") {
|
||||
step = "deleted"
|
||||
return
|
||||
|
|
@ -56,10 +56,10 @@
|
|||
async function doSplit() {
|
||||
step = "applying_split"
|
||||
const splitAction = new SplitAction(
|
||||
id,
|
||||
id.data,
|
||||
splitPoints.data.map((ff) => <[number, number]>(<Point>ff.geometry).coordinates),
|
||||
{
|
||||
theme: state?.theme?.id,
|
||||
theme: state?.theme?.id
|
||||
},
|
||||
snapTolerance
|
||||
)
|
||||
|
|
@ -72,53 +72,54 @@
|
|||
step = "has_been_split"
|
||||
}
|
||||
</script>
|
||||
{#if $id.startsWith("way/")}
|
||||
<LoginToggle ignoreLoading={true} {state}>
|
||||
<Tr slot="not-logged-in" t={t.loginToSplit} />
|
||||
|
||||
<LoginToggle ignoreLoading={true} {state}>
|
||||
<Tr slot="not-logged-in" t={t.loginToSplit} />
|
||||
|
||||
{#if step === "deleted"}
|
||||
<!-- Empty -->
|
||||
{:else if step === "initial"}
|
||||
<button class="w-full" on:click={() => downloadWay()}>
|
||||
<Scissors class="h-6 w-6 shrink-0" />
|
||||
<Tr t={t.inviteToSplit} />
|
||||
</button>
|
||||
{:else if step === "loading_way"}
|
||||
<Loading />
|
||||
{:else if step === "splitting"}
|
||||
<div class="interactive border-interactive flex flex-col p-2">
|
||||
<div class="h-80 w-full">
|
||||
<WaySplitMap
|
||||
{state}
|
||||
{splitPoints}
|
||||
{osmWay}
|
||||
{snapTolerance}
|
||||
mapProperties={{ rasterLayer: state.mapProperties.rasterLayer }}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex w-full flex-wrap-reverse md:flex-nowrap">
|
||||
<BackButton
|
||||
clss="w-full"
|
||||
on:click={() => {
|
||||
{#if step === "deleted"}
|
||||
<!-- Empty -->
|
||||
{:else if step === "initial"}
|
||||
<button class="w-full" on:click={() => downloadWay()}>
|
||||
<Scissors class="h-6 w-6 shrink-0" />
|
||||
<Tr t={t.inviteToSplit} />
|
||||
</button>
|
||||
{:else if step === "loading_way"}
|
||||
<Loading />
|
||||
{:else if step === "splitting"}
|
||||
<div class="interactive border-interactive flex flex-col p-2">
|
||||
<div class="h-80 w-full">
|
||||
<WaySplitMap
|
||||
{state}
|
||||
{splitPoints}
|
||||
{osmWay}
|
||||
{snapTolerance}
|
||||
mapProperties={{ rasterLayer: state.mapProperties.rasterLayer }}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex w-full flex-wrap-reverse md:flex-nowrap">
|
||||
<BackButton
|
||||
clss="w-full"
|
||||
on:click={() => {
|
||||
splitPoints.set([])
|
||||
step = "initial"
|
||||
}}
|
||||
>
|
||||
<Tr t={Translations.t.general.cancel} />
|
||||
</BackButton>
|
||||
<NextButton
|
||||
clss={($splitpointsNotEmpty ? "" : "disabled ") + "w-full primary"}
|
||||
on:click={() => doSplit()}
|
||||
>
|
||||
<Tr t={t.split} />
|
||||
</NextButton>
|
||||
>
|
||||
<Tr t={Translations.t.general.cancel} />
|
||||
</BackButton>
|
||||
<NextButton
|
||||
clss={($splitpointsNotEmpty ? "" : "disabled ") + "w-full primary"}
|
||||
on:click={() => doSplit()}
|
||||
>
|
||||
<Tr t={t.split} />
|
||||
</NextButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else if step === "has_been_split"}
|
||||
<Tr cls="thanks " t={t.hasBeenSplit} />
|
||||
<button on:click={() => downloadWay()}>
|
||||
<Scissors class="h-6 w-6" />
|
||||
<Tr t={t.splitAgain} />
|
||||
</button>
|
||||
{/if}
|
||||
</LoginToggle>
|
||||
{:else if step === "has_been_split"}
|
||||
<Tr cls="thanks " t={t.hasBeenSplit} />
|
||||
<button on:click={() => downloadWay()}>
|
||||
<Scissors class="h-6 w-6" />
|
||||
<Tr t={t.splitAgain} />
|
||||
</button>
|
||||
{/if}
|
||||
</LoginToggle>
|
||||
{/if}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue