mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-11 21:56:00 +00:00
This is necessary for handling undos/redos during multiselection. For example: change a feature's preset or name, select the feature and some others, undo: the selection list should update to display the former preset type and former name. While here, I removed the object indirection and bound entities directly, and I removed hover effects (since the features are selected, you can't see the hover).
70 lines
2.0 KiB
JavaScript
70 lines
2.0 KiB
JavaScript
iD.ui.SelectionList = function(context, selectedIDs) {
|
|
|
|
function selectionList(selection) {
|
|
selection.classed('selection-list-pane', true);
|
|
|
|
var header = selection.append('div')
|
|
.attr('class', 'header fillL cf');
|
|
|
|
header.append('h3')
|
|
.text(t('inspector.multiselect'));
|
|
|
|
var listWrap = selection.append('div')
|
|
.attr('class', 'inspector-body');
|
|
|
|
var list = listWrap.append('div')
|
|
.attr('class', 'feature-list cf');
|
|
|
|
context.history().on('change.selection-list', drawList);
|
|
drawList();
|
|
|
|
function drawList() {
|
|
var entities = selectedIDs
|
|
.map(function(id) { return context.hasEntity(id); })
|
|
.filter(function(entity) { return entity; });
|
|
|
|
var items = list.selectAll('.feature-list-item')
|
|
.data(entities, iD.Entity.key);
|
|
|
|
var enter = items.enter().append('button')
|
|
.attr('class', 'feature-list-item')
|
|
.on('click', function(entity) {
|
|
context.enter(iD.modes.Select(context, [entity.id]));
|
|
});
|
|
|
|
// Enter
|
|
|
|
var label = enter.append('div')
|
|
.attr('class', 'label');
|
|
|
|
label.append('span')
|
|
.attr('class', 'icon icon-pre-text');
|
|
|
|
label.append('span')
|
|
.attr('class', 'entity-type');
|
|
|
|
label.append('span')
|
|
.attr('class', 'entity-name');
|
|
|
|
// Update
|
|
|
|
items.selectAll('.icon')
|
|
.attr('class', function(entity) { return context.geometry(entity.id) + ' icon icon-pre-text'; });
|
|
|
|
items.selectAll('.entity-type')
|
|
.text(function(entity) { return context.presets().match(entity, context.graph()).name(); });
|
|
|
|
items.selectAll('.entity-name')
|
|
.text(function(entity) { return iD.util.displayName(entity); });
|
|
|
|
// Exit
|
|
|
|
items.exit()
|
|
.remove();
|
|
}
|
|
}
|
|
|
|
return selectionList;
|
|
|
|
};
|