mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 18:33:01 +02:00
edit.js - entityList - delete key deletes entities, hold shift to select a group of entities, moved appending single entity to selection to ctrl key
This commit is contained in:
parent
6d4c7cd4f2
commit
5d74858500
1 changed files with 36 additions and 1 deletions
|
@ -35,8 +35,32 @@
|
||||||
function onRowClicked(e) {
|
function onRowClicked(e) {
|
||||||
var id = this.dataset.entityId;
|
var id = this.dataset.entityId;
|
||||||
var selection = [this.dataset.entityId];
|
var selection = [this.dataset.entityId];
|
||||||
if (e.shiftKey) {
|
if (e.ctrlKey) {
|
||||||
selection = selection.concat(selectedEntities);
|
selection = selection.concat(selectedEntities);
|
||||||
|
} else if (e.shiftKey && selectedEntities.length > 0) {
|
||||||
|
var previousItemFound = -1;
|
||||||
|
var clickedItemFound = -1;
|
||||||
|
for (var i in entityList.visibleItems) {
|
||||||
|
if (clickedItemFound === -1 && this.dataset.entityId == entityList.visibleItems[i].values().id) {
|
||||||
|
clickedItemFound = i;
|
||||||
|
} else if(previousItemFound === -1 && selectedEntities[0] == entityList.visibleItems[i].values().id) {
|
||||||
|
previousItemFound = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (previousItemFound !== -1 && clickedItemFound !== -1) {
|
||||||
|
var betweenItems = [];
|
||||||
|
var toItem = Math.max(previousItemFound, clickedItemFound);
|
||||||
|
// skip first and last item in this loop, we add them to selection after the loop
|
||||||
|
for (var i = (Math.min(previousItemFound, clickedItemFound) + 1); i < toItem; i++) {
|
||||||
|
entityList.visibleItems[i].elm.className = 'selected';
|
||||||
|
betweenItems.push(entityList.visibleItems[i].values().id);
|
||||||
|
}
|
||||||
|
if (previousItemFound > clickedItemFound) {
|
||||||
|
// always make sure that we add the items in the right order
|
||||||
|
betweenItems.reverse();
|
||||||
|
}
|
||||||
|
selection = selection.concat(betweenItems, selectedEntities);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedEntities = selection;
|
selectedEntities = selection;
|
||||||
|
@ -151,6 +175,17 @@
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener("keydown", function (e) {
|
||||||
|
if (e.target.nodeName === "INPUT") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var keyCode = e.keyCode;
|
||||||
|
if (keyCode === 46) {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
||||||
|
refreshEntities();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
if (window.EventBridge !== undefined) {
|
if (window.EventBridge !== undefined) {
|
||||||
EventBridge.scriptEventReceived.connect(function(data) {
|
EventBridge.scriptEventReceived.connect(function(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
|
Loading…
Reference in a new issue