mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Only update inspector tag list when necessary
This commit is contained in:
@@ -87,11 +87,12 @@ iD.modes.Select = function (entity) {
|
||||
|
||||
// Exit mode if selected entity gets undone
|
||||
mode.history.on('change.entity-undone', function() {
|
||||
var old = entity;
|
||||
entity = mode.history.graph().entity(entity.id);
|
||||
if (!entity) {
|
||||
mode.controller.enter(iD.modes.Browse());
|
||||
} else {
|
||||
d3.select('.inspector-wrap').datum(entity).call(inspector);
|
||||
} else if(!_.isEqual(entity.tags, old.tags)) {
|
||||
inspector.tags(entity.tags);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ iD.ui.inspector = function() {
|
||||
tags = [{key: '', value: ''}];
|
||||
}
|
||||
|
||||
var li = tagList.selectAll('li')
|
||||
var li = tagList.html('')
|
||||
.selectAll('li')
|
||||
.data(tags, function(d) { return d.key; });
|
||||
|
||||
li.exit().remove();
|
||||
@@ -154,7 +155,6 @@ iD.ui.inspector = function() {
|
||||
if (en.on_node) types.push('point');
|
||||
if (en.on_way) types.push('line');
|
||||
en.types = types;
|
||||
console.log(en);
|
||||
iD.ui.modal()
|
||||
.select('.content')
|
||||
.datum(en)
|
||||
@@ -256,15 +256,19 @@ iD.ui.inspector = function() {
|
||||
event.close(entity);
|
||||
}
|
||||
|
||||
inspector.tags = function () {
|
||||
var tags = {};
|
||||
tagList.selectAll('li').each(function() {
|
||||
var row = d3.select(this),
|
||||
key = row.selectAll('.key').property('value'),
|
||||
value = row.selectAll('.value').property('value');
|
||||
if (key !== '') tags[key] = value;
|
||||
});
|
||||
return tags;
|
||||
inspector.tags = function (tags) {
|
||||
if (!arguments.length) {
|
||||
var tags = {};
|
||||
tagList.selectAll('li').each(function() {
|
||||
var row = d3.select(this),
|
||||
key = row.selectAll('.key').property('value'),
|
||||
value = row.selectAll('.value').property('value');
|
||||
if (key !== '') tags[key] = value;
|
||||
});
|
||||
return tags;
|
||||
} else {
|
||||
drawTags(tags);
|
||||
}
|
||||
};
|
||||
|
||||
return d3.rebind(inspector, event, 'on');
|
||||
|
||||
Reference in New Issue
Block a user