Remove an item from the multiselect list

Fixes #2950
This commit is contained in:
Eric Brelsford
2016-07-25 15:46:54 -04:00
parent 747b9f37d5
commit d15a2e5aa3
2 changed files with 21 additions and 0 deletions

View File

@@ -735,6 +735,14 @@ button.save.has-count .count::before {
opacity: .5;
}
.feature-list-item .label .close {
float: right;
}
.feature-list-item .label .close .icon {
opacity: 1;
}
.feature-list-item:hover .label {
background-color: #ececec;
}

View File

@@ -10,6 +10,14 @@ export function SelectionList(context, selectedIDs) {
context.enter(Select(context, [entity.id]).suppressMenu(true));
}
function deselectEntity(entity) {
d3.event.stopPropagation();
var index = selectedIDs.indexOf(entity.id);
if (index > -1) {
selectedIDs.splice(index, 1);
}
context.enter(Select(context, selectedIDs).suppressMenu(true));
}
function selectionList(selection) {
selection.classed('selection-list-pane', true);
@@ -65,6 +73,11 @@ export function SelectionList(context, selectedIDs) {
items.selectAll('.entity-name')
.text(function(entity) { return displayName(entity); });
label.append('span')
.attr('class', 'close')
.on('click', deselectEntity)
.call(Icon('#icon-close'));
// Exit
items.exit()
.remove();