forked from MapComplete/MapComplete
Fix #2002
This commit is contained in:
parent
1dc219c394
commit
ecfa7d3d1d
3 changed files with 17 additions and 9 deletions
|
@ -47,12 +47,14 @@
|
||||||
async function closeNote() {
|
async function closeNote() {
|
||||||
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)
|
||||||
tags.ping()
|
tags.ping()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reopenNote() {
|
async function reopenNote() {
|
||||||
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)
|
||||||
tags.ping()
|
tags.ping()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -10,6 +10,8 @@ import { UIEventSource } from "../../../Logic/UIEventSource"
|
||||||
import Constants from "../../../Models/Constants"
|
import Constants from "../../../Models/Constants"
|
||||||
import SvelteUIElement from "../../Base/SvelteUIElement"
|
import SvelteUIElement from "../../Base/SvelteUIElement"
|
||||||
import Checkmark from "../../../assets/svg/Checkmark.svelte"
|
import Checkmark from "../../../assets/svg/Checkmark.svelte"
|
||||||
|
import NoteCommentElement from "./NoteCommentElement"
|
||||||
|
import Icon from "../../Map/Icon.svelte"
|
||||||
|
|
||||||
export class CloseNoteButton implements SpecialVisualization {
|
export class CloseNoteButton implements SpecialVisualization {
|
||||||
public readonly funcName = "close_note"
|
public readonly funcName = "close_note"
|
||||||
|
@ -62,10 +64,7 @@ export class CloseNoteButton implements SpecialVisualization {
|
||||||
zoomButton: string
|
zoomButton: string
|
||||||
} = <any>Utils.ParseVisArgs(this.args, args)
|
} = <any>Utils.ParseVisArgs(this.args, args)
|
||||||
|
|
||||||
let icon: BaseUIElement = new SvelteUIElement(Checkmark)
|
let icon: BaseUIElement = new SvelteUIElement(Icon, {icon: params.icon ?? "checkmark.svg"})
|
||||||
if (params.icon !== "checkmark.svg" && (args[2] ?? "") !== "") {
|
|
||||||
icon = new Img(args[1])
|
|
||||||
}
|
|
||||||
let textToShow = t.closeNote
|
let textToShow = t.closeNote
|
||||||
if ((params.text ?? "") !== "") {
|
if ((params.text ?? "") !== "") {
|
||||||
textToShow = Translations.T(args[0])
|
textToShow = Translations.T(args[0])
|
||||||
|
@ -75,7 +74,9 @@ export class CloseNoteButton implements SpecialVisualization {
|
||||||
const isClosed = tags.map((tags) => (tags["closed_at"] ?? "") !== "")
|
const isClosed = tags.map((tags) => (tags["closed_at"] ?? "") !== "")
|
||||||
closeButton.onClick(() => {
|
closeButton.onClick(() => {
|
||||||
const id = tags.data[args[2] ?? "id"]
|
const id = tags.data[args[2] ?? "id"]
|
||||||
state.osmConnection.closeNote(id, args[3])?.then((_) => {
|
const text = args[3]
|
||||||
|
state.osmConnection.closeNote(id, text)?.then((_) => {
|
||||||
|
NoteCommentElement.addCommentTo(text, tags, state)
|
||||||
tags.data["closed_at"] = new Date().toISOString()
|
tags.data["closed_at"] = new Date().toISOString()
|
||||||
tags.ping()
|
tags.ping()
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,8 +6,7 @@ import Translations from "../../i18n/Translations"
|
||||||
import { Utils } from "../../../Utils"
|
import { Utils } from "../../../Utils"
|
||||||
import Img from "../../Base/Img"
|
import Img from "../../Base/Img"
|
||||||
import { SlideShow } from "../../Image/SlideShow"
|
import { SlideShow } from "../../Image/SlideShow"
|
||||||
import { Stores, UIEventSource } from "../../../Logic/UIEventSource"
|
import { Store, Stores, UIEventSource } from "../../../Logic/UIEventSource"
|
||||||
import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
|
|
||||||
import { VariableUiElement } from "../../Base/VariableUIElement"
|
import { VariableUiElement } from "../../Base/VariableUIElement"
|
||||||
import { SpecialVisualizationState } from "../../SpecialVisualization"
|
import { SpecialVisualizationState } from "../../SpecialVisualization"
|
||||||
import SvelteUIElement from "../../Base/SvelteUIElement"
|
import SvelteUIElement from "../../Base/SvelteUIElement"
|
||||||
|
@ -50,7 +49,7 @@ export default class NoteCommentElement extends Combine {
|
||||||
}
|
}
|
||||||
|
|
||||||
const userinfo = Stores.FromPromise(
|
const userinfo = Stores.FromPromise(
|
||||||
Utils.downloadJsonCached(
|
Utils.downloadJsonCached<{user: { img: { href: string } }}>(
|
||||||
"https://api.openstreetmap.org/api/0.6/user/" + comment.uid,
|
"https://api.openstreetmap.org/api/0.6/user/" + comment.uid,
|
||||||
24 * 60 * 60 * 1000
|
24 * 60 * 60 * 1000
|
||||||
)
|
)
|
||||||
|
@ -114,10 +113,16 @@ export default class NoteCommentElement extends Combine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the comment to the _visualisation_ of the given note; doesn't _actually_ upload
|
||||||
|
* @param txt
|
||||||
|
* @param tags
|
||||||
|
* @param state
|
||||||
|
*/
|
||||||
public static addCommentTo(
|
public static addCommentTo(
|
||||||
txt: string,
|
txt: string,
|
||||||
tags: UIEventSource<any>,
|
tags: UIEventSource<any>,
|
||||||
state: { osmConnection: OsmConnection }
|
state: { osmConnection: {userDetails: Store<{ name: string, uid: number }>} }
|
||||||
) {
|
) {
|
||||||
const comments: any[] = JSON.parse(tags.data["comments"])
|
const comments: any[] = JSON.parse(tags.data["comments"])
|
||||||
const username = state.osmConnection.userDetails.data.name
|
const username = state.osmConnection.userDetails.data.name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue