mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-25 23:13:42 +00:00
Also stringify the note id (because existing notes from OSM are this way) Also make sure comments is initialized as an Array not an Object Also clarify some of the tests
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
import { t } from '../util/locale';
|
|
import { behaviorDraw } from '../behavior';
|
|
import { modeBrowse, modeSelectNote } from './index';
|
|
import { osmNote } from '../osm';
|
|
import { services } from '../services';
|
|
|
|
|
|
export function modeAddNote(context) {
|
|
|
|
var mode = {
|
|
id: 'add-note',
|
|
button: 'note',
|
|
title: t('modes.add_note.title'),
|
|
description: t('modes.add_note.description'),
|
|
key: '4'
|
|
};
|
|
|
|
var behavior = behaviorDraw(context)
|
|
.tail(t('modes.add_note.tail'))
|
|
.on('click', add)
|
|
.on('cancel', cancel)
|
|
.on('finish', cancel);
|
|
|
|
|
|
function add(loc) {
|
|
var osm = services.osm;
|
|
if (!osm) return;
|
|
|
|
var note = osmNote({ loc: loc, status: 'open', comments: [] });
|
|
osm.replaceNote(note);
|
|
|
|
context
|
|
.selectedNoteID(note.id)
|
|
.enter(modeSelectNote(context, note.id).newFeature(true));
|
|
}
|
|
|
|
|
|
function cancel() {
|
|
context.enter(modeBrowse(context));
|
|
}
|
|
|
|
|
|
mode.enter = function() {
|
|
context.install(behavior);
|
|
};
|
|
|
|
|
|
mode.exit = function() {
|
|
context.uninstall(behavior);
|
|
};
|
|
|
|
|
|
return mode;
|
|
}
|