mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-02 10:02:12 +00:00
fix sortable
This commit is contained in:
@@ -28,16 +28,7 @@
|
|||||||
setContext('recursive', recursive);
|
setContext('recursive', recursive);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (orientation === 'vertical') {
|
if (orientation === 'horizontal') {
|
||||||
selection.update(($selection) => {
|
|
||||||
$selection.forEach((item) => {
|
|
||||||
if ($selection.hasAnyChildren(item, false)) {
|
|
||||||
$selection.toggle(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return $selection;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
selection.update(($selection) => {
|
selection.update(($selection) => {
|
||||||
$selection.forEach((item) => {
|
$selection.forEach((item) => {
|
||||||
if (!(item instanceof ListFileItem)) {
|
if (!(item instanceof ListFileItem)) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (sortable) {
|
if (sortable && node) {
|
||||||
sortable.updateElements();
|
sortable.updateElements();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { get, writable, type Readable } from 'svelte/store';
|
|||||||
import { settings } from '$lib/logic/settings';
|
import { settings } from '$lib/logic/settings';
|
||||||
import type { GPXFileWithStatistics } from '$lib/logic/statistics-tree';
|
import type { GPXFileWithStatistics } from '$lib/logic/statistics-tree';
|
||||||
import type { AnyGPXTreeElement, GPXTreeElement, Waypoint } from 'gpx';
|
import type { AnyGPXTreeElement, GPXTreeElement, Waypoint } from 'gpx';
|
||||||
|
import { tick } from 'svelte';
|
||||||
|
|
||||||
const { fileOrder } = settings;
|
const { fileOrder } = settings;
|
||||||
|
|
||||||
@@ -89,7 +90,9 @@ export class SortableFileList {
|
|||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._unsubscribes.push(selection.subscribe(() => this.updateFromSelection()));
|
this._unsubscribes.push(
|
||||||
|
selection.subscribe(() => tick().then(() => this.updateFromSelection()))
|
||||||
|
);
|
||||||
this._unsubscribes.push(fileOrder.subscribe(() => this.updateFromFileOrder()));
|
this._unsubscribes.push(fileOrder.subscribe(() => this.updateFromFileOrder()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,9 +175,8 @@ export class SortableFileList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateToSelection(e: Sortable.SortableEvent) {
|
updateToSelection(e: Sortable.SortableEvent) {
|
||||||
if (this._updatingSelection) {
|
if (!this._sortable) return;
|
||||||
return;
|
if (this._updatingSelection) return;
|
||||||
}
|
|
||||||
this._updatingSelection = true;
|
this._updatingSelection = true;
|
||||||
const changed = this.getChangedIds();
|
const changed = this.getChangedIds();
|
||||||
if (changed.length == 0) {
|
if (changed.length == 0) {
|
||||||
@@ -200,7 +202,6 @@ export class SortableFileList {
|
|||||||
$selection.clear();
|
$selection.clear();
|
||||||
$selection.set(this._item.extend(this.getRealId(changed[0])), true);
|
$selection.set(this._item.extend(this.getRealId(changed[0])), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $selection;
|
return $selection;
|
||||||
});
|
});
|
||||||
this._updatingSelection = false;
|
this._updatingSelection = false;
|
||||||
@@ -255,6 +256,7 @@ export class SortableFileList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
this._sortable = null;
|
||||||
this._unsubscribes.forEach((unsubscribe) => unsubscribe());
|
this._unsubscribes.forEach((unsubscribe) => unsubscribe());
|
||||||
this._unsubscribes = [];
|
this._unsubscribes = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,13 +52,13 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fileStateCollection.connectToDatabase(db);
|
|
||||||
settings.connectToDatabase(db);
|
settings.connectToDatabase(db);
|
||||||
|
fileStateCollection.connectToDatabase(db);
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
fileStateCollection.disconnectFromDatabase();
|
|
||||||
settings.disconnectFromDatabase();
|
settings.disconnectFromDatabase();
|
||||||
|
fileStateCollection.disconnectFromDatabase();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user