forked from MapComplete/MapComplete
Add 'add new note' functionality, fix bug where 'test'-theme comes up when deleting images
This commit is contained in:
parent
e562975f6b
commit
6ae8ec8036
16 changed files with 212 additions and 59 deletions
|
@ -223,7 +223,7 @@ export class OsmConnection {
|
|||
if ((text ?? "") !== "") {
|
||||
textSuffix = "?text=" + encodeURIComponent(text)
|
||||
}
|
||||
if(this._dryRun){
|
||||
if (this._dryRun) {
|
||||
console.warn("Dryrun enabled - not actually closing note ", id, " with text ", text)
|
||||
return new Promise((ok, error) => {
|
||||
ok()
|
||||
|
@ -232,7 +232,7 @@ export class OsmConnection {
|
|||
return new Promise((ok, error) => {
|
||||
this.auth.xhr({
|
||||
method: 'POST',
|
||||
path: `/api/0.6/notes/${id}/close${textSuffix}`
|
||||
path: `/api/0.6/notes/${id}/close${textSuffix}`,
|
||||
}, function (err, response) {
|
||||
if (err !== null) {
|
||||
error(err)
|
||||
|
@ -246,7 +246,7 @@ export class OsmConnection {
|
|||
}
|
||||
|
||||
public reopenNote(id: number | string, text?: string): Promise<any> {
|
||||
if(this._dryRun){
|
||||
if (this._dryRun) {
|
||||
console.warn("Dryrun enabled - not actually reopening note ", id, " with text ", text)
|
||||
return new Promise((ok, error) => {
|
||||
ok()
|
||||
|
@ -272,9 +272,40 @@ export class OsmConnection {
|
|||
|
||||
}
|
||||
|
||||
public openNote(lat: number, lon: number, text: string): Promise<{ id: number }> {
|
||||
if (this._dryRun) {
|
||||
console.warn("Dryrun enabled - not actually opening note with text ", text)
|
||||
return new Promise((ok, error) => {
|
||||
ok()
|
||||
});
|
||||
}
|
||||
const auth = this.auth;
|
||||
const content = {lat, lon, text}
|
||||
return new Promise((ok, error) => {
|
||||
auth.xhr({
|
||||
method: 'POST',
|
||||
path: `/api/0.6/notes.json`,
|
||||
options: {header:
|
||||
{'Content-Type': 'application/json'}},
|
||||
content: JSON.stringify(content)
|
||||
|
||||
}, function (err, response) {
|
||||
if (err !== null) {
|
||||
error(err)
|
||||
} else {
|
||||
const id = Number(response.children[0].children[0].children.item("id").innerHTML)
|
||||
console.log("OPENED NOTE", id)
|
||||
ok({id})
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
public addCommentToNode(id: number | string, text: string): Promise<any> {
|
||||
if(this._dryRun){
|
||||
console.warn("Dryrun enabled - not actually adding comment ",text, "to note ", id)
|
||||
if (this._dryRun) {
|
||||
console.warn("Dryrun enabled - not actually adding comment ", text, "to note ", id)
|
||||
return new Promise((ok, error) => {
|
||||
ok()
|
||||
});
|
||||
|
@ -286,7 +317,8 @@ export class OsmConnection {
|
|||
return new Promise((ok, error) => {
|
||||
this.auth.xhr({
|
||||
method: 'POST',
|
||||
path: `/api/0.6/notes/${id}/comment?text=${encodeURIComponent(text)}`
|
||||
|
||||
path: `/api/0.6/notes.json/${id}/comment?text=${encodeURIComponent(text)}`
|
||||
}, function (err, response) {
|
||||
if (err !== null) {
|
||||
error(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue