From 062872c4f0c4b87e7481fbce84afd4c4efa17cb5 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 5 Mar 2019 09:39:55 -0500 Subject: [PATCH] Merge tags instead of adding new point when adding a point to a point Fix lint error --- modules/modes/add_point.js | 22 ++++++++++++++++++++-- modules/ui/modes.js | 1 - modules/ui/search_add.js | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/modes/add_point.js b/modules/modes/add_point.js index 1b8b7792e..d3c490d72 100644 --- a/modules/modes/add_point.js +++ b/modules/modes/add_point.js @@ -1,5 +1,7 @@ +import _clone from 'lodash-es/clone'; + import { t } from '../util/locale'; -import { actionAddEntity } from '../actions'; +import { actionAddEntity, actionChangeTags } from '../actions'; import { behaviorDraw } from '../behavior'; import { modeBrowse, modeSelect } from './index'; import { osmNode } from '../osm'; @@ -53,7 +55,23 @@ export function modeAddPoint(context, mode) { function addNode(node) { - add(node.loc); + + if (Object.keys(defaultTags).length === 0) { + enterSelectMode(node); + return; + } + + var tags = _clone(node.tags); + for (var key in defaultTags) { + tags[key] = defaultTags[key]; + } + + context.perform( + actionChangeTags(node.id, tags), + t('operations.add.annotation.point') + ); + + enterSelectMode(node); } diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 5af3c3e64..3f15702dc 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -83,7 +83,6 @@ export function uiModes(context) { button: markerClass, title: presetName, description: t(tooltipTitleID, { feature: presetName }), - key: '', preset: preset, geometry: d.geom }; diff --git a/modules/ui/search_add.js b/modules/ui/search_add.js index 2734a0639..32f579677 100644 --- a/modules/ui/search_add.js +++ b/modules/ui/search_add.js @@ -173,7 +173,7 @@ export function uiSearchAdd(context) { if (!selection.empty()) { selection.classed('focused', true); // scroll to keep the focused item visible - scrollPopoverToShow(selection) + scrollPopoverToShow(selection); } }