mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-19 17:43:39 +00:00
This is a facade interface that ties together a bunch of different internal objects and will make it easier to write tests for behaviors, modes, and operations.
31 lines
922 B
JavaScript
31 lines
922 B
JavaScript
iD.operations.Delete = function(selection, context) {
|
|
var entityId = selection[0];
|
|
|
|
var operation = function() {
|
|
var entity = context.entity(entityId),
|
|
action = {way: iD.actions.DeleteWay, node: iD.actions.DeleteNode}[entity.type],
|
|
annotation = t('operations.delete.annotation.' + context.geometry(entityId));
|
|
|
|
context.perform(
|
|
action(entityId),
|
|
annotation);
|
|
};
|
|
|
|
operation.available = function() {
|
|
var entity = context.entity(entityId);
|
|
return selection.length === 1 &&
|
|
(entity.type === 'way' || entity.type === 'node');
|
|
};
|
|
|
|
operation.enabled = function() {
|
|
return true;
|
|
};
|
|
|
|
operation.id = "delete";
|
|
operation.key = t('operations.delete.key');
|
|
operation.title = t('operations.delete.title');
|
|
operation.description = t('operations.delete.description');
|
|
|
|
return operation;
|
|
};
|