fix dnd bugs
This commit is contained in:
parent
5f7155090b
commit
69334d977d
2 changed files with 22 additions and 4 deletions
|
@ -164,18 +164,30 @@
|
||||||
if (sortableLevel === ListLevel.FILE) {
|
if (sortableLevel === ListLevel.FILE) {
|
||||||
Object.keys(elements).forEach((fileId) => {
|
Object.keys(elements).forEach((fileId) => {
|
||||||
if (!get(fileObservers).has(fileId)) {
|
if (!get(fileObservers).has(fileId)) {
|
||||||
|
if (elements[fileId]) {
|
||||||
|
Sortable.utils.deselect(elements[fileId]);
|
||||||
|
}
|
||||||
delete elements[fileId];
|
delete elements[fileId];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (sortableLevel === ListLevel.WAYPOINTS) {
|
} else if (sortableLevel === ListLevel.WAYPOINTS) {
|
||||||
if (node.wpt.length === 0) {
|
if (node.wpt.length === 0) {
|
||||||
|
if (elements['waypoints']) {
|
||||||
|
Sortable.utils.deselect(elements['waypoints']);
|
||||||
|
}
|
||||||
delete elements['waypoints'];
|
delete elements['waypoints'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Object.keys(elements).forEach((index) => {
|
Object.keys(elements).forEach((index) => {
|
||||||
if ((node instanceof GPXFile || node instanceof Track) && node.children.length <= index) {
|
if ((node instanceof GPXFile || node instanceof Track) && node.children.length <= index) {
|
||||||
|
if (elements[index]) {
|
||||||
|
Sortable.utils.deselect(elements[index]);
|
||||||
|
}
|
||||||
delete elements[index];
|
delete elements[index];
|
||||||
} else if (Array.isArray(node) && node.length <= index) {
|
} else if (Array.isArray(node) && node.length <= index) {
|
||||||
|
if (elements[index]) {
|
||||||
|
Sortable.utils.deselect(elements[index]);
|
||||||
|
}
|
||||||
delete elements[index];
|
delete elements[index];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -183,6 +195,10 @@
|
||||||
if (sortableLevel !== ListLevel.FILE) {
|
if (sortableLevel !== ListLevel.FILE) {
|
||||||
sortable.sort(Object.keys(elements));
|
sortable.sort(Object.keys(elements));
|
||||||
}
|
}
|
||||||
|
Object.defineProperty(sortable, '_item', {
|
||||||
|
value: item,
|
||||||
|
writable: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const unsubscribe = selection.subscribe(($selection) => {
|
const unsubscribe = selection.subscribe(($selection) => {
|
||||||
|
|
|
@ -289,16 +289,18 @@ export class GPXLayer {
|
||||||
|
|
||||||
showWaypointPopup(waypoint: Waypoint) {
|
showWaypointPopup(waypoint: Waypoint) {
|
||||||
let marker = this.markers[waypoint._data.index];
|
let marker = this.markers[waypoint._data.index];
|
||||||
currentWaypoint.set(waypoint);
|
if (marker) {
|
||||||
marker.setPopup(waypointPopup);
|
currentWaypoint.set(waypoint);
|
||||||
marker.togglePopup();
|
marker.setPopup(waypointPopup);
|
||||||
|
marker.togglePopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideWaypointPopup() {
|
hideWaypointPopup() {
|
||||||
let waypoint = get(currentWaypoint);
|
let waypoint = get(currentWaypoint);
|
||||||
if (waypoint) {
|
if (waypoint) {
|
||||||
let marker = this.markers[waypoint._data.index];
|
let marker = this.markers[waypoint._data.index];
|
||||||
marker.getPopup()?.remove();
|
marker?.getPopup()?.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue