Fix #2014
This commit is contained in:
parent
65176122c2
commit
4166c4b863
1 changed files with 16 additions and 0 deletions
|
@ -9,6 +9,8 @@
|
||||||
import Resolved from "../../../assets/svg/Resolved.svelte"
|
import Resolved from "../../../assets/svg/Resolved.svelte"
|
||||||
import Note from "../../../assets/svg/Note.svelte"
|
import Note from "../../../assets/svg/Note.svelte"
|
||||||
import LoginToggle from "../../Base/LoginToggle.svelte"
|
import LoginToggle from "../../Base/LoginToggle.svelte"
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
import Loading from "../../Base/Loading.svelte"
|
||||||
|
|
||||||
export let state: SpecialVisualizationState
|
export let state: SpecialVisualizationState
|
||||||
export let tags: UIEventSource<Record<string, string>>
|
export let tags: UIEventSource<Record<string, string>>
|
||||||
|
@ -29,11 +31,14 @@
|
||||||
|
|
||||||
let isClosed: Store<boolean> = tags.map((tags) => (tags?.["closed_at"] ?? "") !== "")
|
let isClosed: Store<boolean> = tags.map((tags) => (tags?.["closed_at"] ?? "") !== "")
|
||||||
|
|
||||||
|
let isProcessing = writable(false)
|
||||||
async function addComment() {
|
async function addComment() {
|
||||||
if ((txt.data ?? "") == "") {
|
if ((txt.data ?? "") == "") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isProcessing.set(true)
|
||||||
|
|
||||||
if (isClosed.data) {
|
if (isClosed.data) {
|
||||||
await state.osmConnection.reopenNote(id, txt.data)
|
await state.osmConnection.reopenNote(id, txt.data)
|
||||||
await state.osmConnection.closeNote(id)
|
await state.osmConnection.closeNote(id)
|
||||||
|
@ -42,20 +47,27 @@
|
||||||
}
|
}
|
||||||
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
||||||
txt.setData("")
|
txt.setData("")
|
||||||
|
isProcessing.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeNote() {
|
async function closeNote() {
|
||||||
|
isProcessing.set(true)
|
||||||
await state.osmConnection.closeNote(id, txt.data)
|
await state.osmConnection.closeNote(id, txt.data)
|
||||||
tags.data["closed_at"] = new Date().toISOString()
|
tags.data["closed_at"] = new Date().toISOString()
|
||||||
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
||||||
tags.ping()
|
tags.ping()
|
||||||
|
isProcessing.set(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reopenNote() {
|
async function reopenNote() {
|
||||||
|
isProcessing.set(true)
|
||||||
await state.osmConnection.reopenNote(id, txt.data)
|
await state.osmConnection.reopenNote(id, txt.data)
|
||||||
tags.data["closed_at"] = undefined
|
tags.data["closed_at"] = undefined
|
||||||
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
||||||
tags.ping()
|
tags.ping()
|
||||||
|
isProcessing.set(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -76,6 +88,9 @@
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
{#if $isProcessing}
|
||||||
|
<Loading/>
|
||||||
|
{:else}
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
{#if $txt?.length > 0}
|
{#if $txt?.length > 0}
|
||||||
<button class="primary flex" on:click|preventDefault={() => addComment()}>
|
<button class="primary flex" on:click|preventDefault={() => addComment()}>
|
||||||
|
@ -111,5 +126,6 @@
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</form>
|
</form>
|
||||||
</LoginToggle>
|
</LoginToggle>
|
||||||
|
|
Loading…
Reference in a new issue