forked from MapComplete/MapComplete
Fix: fix #2549
This commit is contained in:
parent
604ea6fb3e
commit
abe81abb22
7 changed files with 49 additions and 20 deletions
|
@ -618,6 +618,7 @@
|
|||
"seeNearby": "Browse nearby pictures",
|
||||
"title": "Nearby streetview imagery"
|
||||
},
|
||||
"noteReopen": "Adding a picture will reopen the note",
|
||||
"openOnWebsite": "Open this image on {name}",
|
||||
"panoramax": {
|
||||
"deletionRequested": "The report has been sent. A moderator will look to it shortly",
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
import type { Feature } from "geojson"
|
||||
import Camera from "@babeard/svelte-heroicons/mini/Camera"
|
||||
import ArrowUpTray from "@babeard/svelte-heroicons/solid/ArrowUpTray"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import NoteCommentElement from "../Popup/Notes/NoteCommentElement"
|
||||
|
||||
export let state: SpecialVisualizationState
|
||||
|
||||
|
@ -23,6 +25,7 @@
|
|||
export let targetKey: string = undefined
|
||||
export let noBlur: boolean = false
|
||||
export let feature: Feature
|
||||
export let layer: LayerConfig
|
||||
/**
|
||||
* Image to show in the button
|
||||
* NOT the image to upload!
|
||||
|
@ -33,6 +36,8 @@
|
|||
}
|
||||
export let labelText: string = undefined
|
||||
const t = Translations.t.image
|
||||
const isNote = layer.id === "note"
|
||||
const noteIsOpened = tags.mapD(tags => tags.closed_at === undefined)
|
||||
|
||||
let errors = new UIEventSource<Translation[]>([])
|
||||
|
||||
|
@ -47,7 +52,15 @@
|
|||
errs.push(canBeUploaded.error)
|
||||
continue
|
||||
}
|
||||
await state?.imageUploadManager?.uploadImageAndApply(
|
||||
|
||||
if (isNote) {
|
||||
if (!noteIsOpened.data) {
|
||||
await state.osmConnection.reopenNote(tags.data.id)
|
||||
NoteCommentElement.mimickStatusChange(tags, true)
|
||||
}
|
||||
}
|
||||
|
||||
state?.imageUploadManager?.uploadImageAndApply(
|
||||
file,
|
||||
tags,
|
||||
targetKey,
|
||||
|
@ -109,6 +122,9 @@
|
|||
<Tr t={t.upload.noBlur} />
|
||||
</span>
|
||||
{/if}
|
||||
{#if isNote && !$noteIsOpened}
|
||||
<Tr t={t.noteReopen} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</FileSelector>
|
||||
|
@ -150,14 +166,20 @@
|
|||
<Tr t={t.upload.noBlur} />
|
||||
</span>
|
||||
{/if}
|
||||
{#if isNote && !$noteIsOpened}
|
||||
<Tr t={t.noteReopen} />
|
||||
{/if}
|
||||
</div>
|
||||
</FileSelector>
|
||||
|
||||
|
||||
<div class="subtle text-xs italic">
|
||||
<Tr t={Translations.t.general.attribution.panoramaxLicenseCCBYSA} />
|
||||
<span class="mx-1">—</span>
|
||||
<Tr t={t.respectPrivacy} />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
</LoginToggle>
|
||||
|
|
|
@ -7,6 +7,7 @@ import Maproulette from "../../../Logic/Maproulette"
|
|||
import { GeoOperations } from "../../../Logic/GeoOperations"
|
||||
import { Tag } from "../../../Logic/Tags/Tag"
|
||||
import { SpecialVisualizationState } from "../../SpecialVisualization"
|
||||
import NoteCommentElement from "../Notes/NoteCommentElement"
|
||||
|
||||
export interface PointImportFlowArguments extends ImportFlowArguments {
|
||||
max_snap_distance?: string
|
||||
|
@ -74,8 +75,7 @@ export class PointImportFlowState extends ImportFlow<PointImportFlowArguments> {
|
|||
|
||||
if (note_id !== undefined) {
|
||||
await this.state.osmConnection.closeNote(note_id, "imported")
|
||||
originalFeatureTags.data["closed_at"] = new Date().toISOString()
|
||||
originalFeatureTags.ping()
|
||||
NoteCommentElement.mimickStatusChange(originalFeatureTags, false)
|
||||
}
|
||||
|
||||
const maproulette_id = originalFeatureTags.data[this.args.maproulette_id]
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
if (isClosed.data) {
|
||||
await state.osmConnection.reopenNote(id, txt.data)
|
||||
await state.osmConnection.closeNote(id)
|
||||
NoteCommentElement.mimickStatusChange(tags, false)
|
||||
} else {
|
||||
await state.osmConnection.addCommentToNote(id, txt.data)
|
||||
}
|
||||
|
@ -54,16 +55,15 @@
|
|||
async function closeNote() {
|
||||
isProcessing.set(true)
|
||||
await state.osmConnection.closeNote(id, txt.data)
|
||||
isProcessing.set(false)
|
||||
tags.data["closed_at"] = new Date().toISOString()
|
||||
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
||||
tags.ping()
|
||||
NoteCommentElement.mimickStatusChange(tags, false) // Will ping
|
||||
isProcessing.set(false)
|
||||
}
|
||||
|
||||
async function reopenNote() {
|
||||
isProcessing.set(true)
|
||||
await state.osmConnection.reopenNote(id, txt.data)
|
||||
tags.data["closed_at"] = undefined
|
||||
NoteCommentElement.mimickStatusChange(tags, true)
|
||||
NoteCommentElement.addCommentTo(txt.data, tags, state)
|
||||
tags.ping()
|
||||
txt.set(undefined)
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
const id = tags.data[idkey]
|
||||
await state.osmConnection.closeNote(id, message)
|
||||
NoteCommentElement.addCommentTo(message, tags, state)
|
||||
tags.data["closed_at"] = new Date().toISOString()
|
||||
tags.ping()
|
||||
NoteCommentElement.mimickStatusChange(tags, false)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
import { Store, UIEventSource } from "../../../Logic/UIEventSource"
|
||||
|
||||
export default class NoteCommentElement {
|
||||
|
||||
public static mimickStatusChange(tags: UIEventSource<Record<string, string>>, opened: boolean) {
|
||||
if (opened) {
|
||||
tags.data.status = "open"
|
||||
tags.data.closed_at = undefined
|
||||
} else {
|
||||
tags.data.status = "closed"
|
||||
tags.data.closed_at = new Date().toISOString()
|
||||
}
|
||||
tags.ping()
|
||||
}
|
||||
/**
|
||||
* Adds the comment to the _visualisation_ of the given note; doesn't _actually_ upload
|
||||
* @param txt
|
||||
|
@ -16,9 +27,9 @@ export default class NoteCommentElement {
|
|||
const username = state.osmConnection.userDetails.data.name
|
||||
|
||||
const urlRegex = /(https?:\/\/[^\s]+)/g
|
||||
const html = txt.replace(urlRegex, function (url) {
|
||||
const html = txt?.replace(urlRegex, function(url) {
|
||||
return '<a href="' + url + '">' + url + "</a>"
|
||||
})
|
||||
}) ?? ""
|
||||
|
||||
comments.push({
|
||||
date: new Date().toISOString(),
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
SpecialVisualisationParams,
|
||||
SpecialVisualization,
|
||||
SpecialVisualizationSvelte,
|
||||
} from "../SpecialVisualization"
|
||||
import { SpecialVisualisationParams, SpecialVisualization, SpecialVisualizationSvelte } from "../SpecialVisualization"
|
||||
import Constants from "../../Models/Constants"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { Feature } from "geojson"
|
||||
|
@ -126,10 +122,10 @@ class AddImageToNote extends SpecialVisualizationSvelte {
|
|||
group = "notes"
|
||||
needsUrls = []
|
||||
|
||||
constr({ state, tags, args, feature }: SpecialVisualisationParams) {
|
||||
const id = tags.data[args[0] ?? "id"]
|
||||
tags = state.featureProperties.getStore(id)
|
||||
return new SvelteUIElement(UploadImage, { state, tags, feature })
|
||||
constr(params: SpecialVisualisationParams) {
|
||||
const id = params.tags.data[params.args[0] ?? "id"]
|
||||
const tags = params.state.featureProperties.getStore(id)
|
||||
return new SvelteUIElement(UploadImage, { ...params, tags })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue