mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-04 14:08:13 +02:00
prevent dragging existing, prevent deleting existing
This commit is contained in:
@@ -7,6 +7,11 @@ export function actionDeleteNode(nodeId) {
|
||||
var action = function(graph) {
|
||||
var node = graph.entity(nodeId);
|
||||
|
||||
// Prevent deletion of existing nodes (anti-vandalism)
|
||||
if (node.version) {
|
||||
throw new Error('Deletion of existing features is not allowed.');
|
||||
}
|
||||
|
||||
graph.parentWays(node)
|
||||
.forEach(function(parent) {
|
||||
parent = parent.removeNode(nodeId);
|
||||
|
||||
@@ -130,8 +130,9 @@ export function modeDragNode(context) {
|
||||
function start(d3_event, entity) {
|
||||
_wasMidpoint = entity.type === 'midpoint';
|
||||
var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
|
||||
_isCancelled = !context.editable() || d3_event.shiftKey || hasHidden;
|
||||
|
||||
var isNewFeature = !entity.version;
|
||||
// var isALPR = entity.tags && entity.tags['surveillance:type'] === 'ALPR'; // Allow ALPR editing
|
||||
_isCancelled = !context.editable() || d3_event.shiftKey || hasHidden || !isNewFeature;
|
||||
|
||||
if (_isCancelled) {
|
||||
if (hasHidden) {
|
||||
@@ -139,6 +140,11 @@ export function modeDragNode(context) {
|
||||
.duration(4000)
|
||||
.iconName('#iD-icon-no')
|
||||
.label(t.append('modes.drag_node.connected_to_hidden'))();
|
||||
} else if (!isNewFeature) {
|
||||
context.ui().flash
|
||||
.duration(4000)
|
||||
.iconName('#iD-icon-no')
|
||||
.label(t.append('modes.drag_node.editing_existing_not_allowed'))();
|
||||
}
|
||||
return drag.cancel();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ export function uiToolDrawModes(context) {
|
||||
|
||||
var wrap = selection
|
||||
.append('div')
|
||||
.attr('class', 'joined')
|
||||
.style('display', 'flex');
|
||||
|
||||
var debouncedUpdate = _debounce(update, 500, { leading: true, trailing: true });
|
||||
|
||||
Reference in New Issue
Block a user