mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Delete multiple
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
<script src='js/id/actions/add_entity.js'></script>
|
||||
<script src='js/id/actions/add_vertex.js'></script>
|
||||
<script src='js/id/actions/change_tags.js'></script>
|
||||
<script src='js/id/actions/delete_multiple.js'></script>
|
||||
<script src='js/id/actions/delete_node.js'></script>
|
||||
<script src="js/id/actions/delete_relation.js"></script>
|
||||
<script src="js/id/actions/delete_way.js"></script>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
iD.actions.DeleteMultiple = function(ids) {
|
||||
return function(graph) {
|
||||
var actions = {
|
||||
way: iD.actions.DeleteWay,
|
||||
node: iD.actions.DeleteNode,
|
||||
relation: iD.actions.DeleteRelation
|
||||
};
|
||||
|
||||
ids.forEach(function (id) {
|
||||
graph = actions[graph.entity(id).type](id)(graph);
|
||||
});
|
||||
|
||||
return graph;
|
||||
};
|
||||
};
|
||||
@@ -1,22 +1,20 @@
|
||||
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,
|
||||
relation: iD.actions.DeleteRelation
|
||||
}[entity.type],
|
||||
annotation = t('operations.delete.annotation.' + context.geometry(entityId));
|
||||
var annotation;
|
||||
|
||||
if (selection.length === 1) {
|
||||
annotation = t('operations.delete.annotation.' + context.geometry(selection[0]));
|
||||
} else {
|
||||
annotation = t('operations.delete.annotation.multiple', {n: selection.length});
|
||||
}
|
||||
|
||||
context.perform(
|
||||
action(entityId),
|
||||
iD.actions.DeleteMultiple(selection),
|
||||
annotation);
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
return selection.length === 1;
|
||||
return true;
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
|
||||
+2
-1
@@ -73,7 +73,8 @@ locale.en = {
|
||||
point: "Deleted a point.",
|
||||
vertex: "Deleted a node from a way.",
|
||||
line: "Deleted a line.",
|
||||
area: "Deleted an area."
|
||||
area: "Deleted an area.",
|
||||
multiple: "Deleted {n} objects."
|
||||
}
|
||||
},
|
||||
move: {
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
<script src='../js/id/actions/add_vertex.js'></script>
|
||||
<script src='../js/id/actions/change_tags.js'></script>
|
||||
<script src='../js/id/actions/circularize.js'></script>
|
||||
<script src="../js/id/actions/delete_multiple.js"></script>
|
||||
<script src="../js/id/actions/delete_node.js"></script>
|
||||
<script src="../js/id/actions/delete_relation.js"></script>
|
||||
<script src="../js/id/actions/delete_way.js"></script>
|
||||
@@ -141,6 +142,7 @@
|
||||
<script src="spec/actions/add_midpoint.js"></script>
|
||||
<script src="spec/actions/add_entity.js"></script>
|
||||
<script src="spec/actions/change_tags.js"></script>
|
||||
<script src="spec/actions/delete_multiple.js"></script>
|
||||
<script src="spec/actions/delete_node.js"></script>
|
||||
<script src="spec/actions/delete_relation.js"></script>
|
||||
<script src="spec/actions/delete_way.js"></script>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<script src="spec/actions/add_midpoint.js"></script>
|
||||
<script src="spec/actions/add_entity.js"></script>
|
||||
<script src="spec/actions/change_tags.js"></script>
|
||||
<script src="spec/actions/delete_multiple.js"></script>
|
||||
<script src="spec/actions/delete_node.js"></script>
|
||||
<script src="spec/actions/delete_relation.js"></script>
|
||||
<script src="spec/actions/delete_way.js"></script>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
describe("iD.actions.DeleteMultiple", function () {
|
||||
it("deletes multiple entities of heterogeneous types", function () {
|
||||
var n = iD.Node(),
|
||||
w = iD.Way(),
|
||||
r = iD.Relation(),
|
||||
action = iD.actions.DeleteMultiple([n.id, w.id, r.id]),
|
||||
graph = action(iD.Graph([n, w, r]));
|
||||
expect(graph.entity(n.id)).to.be.undefined;
|
||||
expect(graph.entity(w.id)).to.be.undefined;
|
||||
expect(graph.entity(r.id)).to.be.undefined;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user