From 525f9fdc51289127cc2151f618d6daae99632e26 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 5 Nov 2012 16:24:06 -0500 Subject: [PATCH] Support changing tags --- js/iD/actions/operations.js | 10 ++++++++++ js/iD/graph/Node.js | 21 --------------------- js/iD/graph/Relation.js | 13 ------------- js/iD/renderer/Map.js | 8 ++++++-- 4 files changed, 16 insertions(+), 36 deletions(-) diff --git a/js/iD/actions/operations.js b/js/iD/actions/operations.js index 873fa6fe9..76b9af4cd 100644 --- a/js/iD/actions/operations.js +++ b/js/iD/actions/operations.js @@ -38,6 +38,16 @@ iD.operations.addTemporary = function(map, node) { map.update(); }; +iD.operations.changeTags = function(map, node, tags) { + map.graph.modify(function(graph) { + var o = {}; + var copy = pdata.object(node).set({ tags: tags }).get(); + o[copy.id] = copy; + return graph.set(o); + }, 'changed tags'); + map.update(); +}; + iD.operations.removeTemporary = function(map, node) { map.graph.modify(function(graph) { return graph.remove(node.id); diff --git a/js/iD/graph/Node.js b/js/iD/graph/Node.js index e7e875763..e69de29bb 100644 --- a/js/iD/graph/Node.js +++ b/js/iD/graph/Node.js @@ -1,21 +0,0 @@ -/* -iD.Node = function(id, lat, lon, tags, loaded) { - this.id = id; - this.lat = lat; - this.lon = lon; - this.tags = tags || {}; - this.children = []; - this.loaded = (loaded === undefined) ? true : loaded; -}; - -iD.Node.prototype = { - type: 'node', - - intersects: function(extent) { - return (this.lon >= extent[0][0]) && - (this.lon <= extent[1][0]) && - (this.lat <= extent[0][1]) && - (this.lat >= extent[1][1]); - } -}; -*/ diff --git a/js/iD/graph/Relation.js b/js/iD/graph/Relation.js index a72968e9f..e69de29bb 100644 --- a/js/iD/graph/Relation.js +++ b/js/iD/graph/Relation.js @@ -1,13 +0,0 @@ -iD.Relation = function(id, uid, children, tags, loaded) { - this.id = id; - this.uid = uid; - this.children = children || []; - this.tags = tags || {}; - this.loaded = (loaded === undefined) ? true : loaded; -}; - -iD.Relation.prototype = { - type: 'relation', - - intersects: function() { return true; } -}; diff --git a/js/iD/renderer/Map.js b/js/iD/renderer/Map.js index 9bdc1a937..06ee5363c 100755 --- a/js/iD/renderer/Map.js +++ b/js/iD/renderer/Map.js @@ -221,11 +221,15 @@ iD.Map = function(elem) { selection = [d.id]; drawVector(); d3.select('.inspector-wrap') - .style('display', 'block') - .datum(d).call(inspector); + .style('display', 'block') + .datum(d).call(inspector); d3.event.stopPropagation(); } + inspector.on('change', function(d, tags) { + iD.operations.changeTags(map, d, tags); + }); + function zoomPan() { projection .translate(d3.event.translate)