mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
shortcut to select all
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
import { fileOrder, files, selectedFiles, selectFiles } from '$lib/stores';
|
||||
|
||||
import { ScrollArea } from '$lib/components/ui/scroll-area/index';
|
||||
|
||||
import Sortable from 'sortablejs/Sortable';
|
||||
|
||||
import { onMount, tick } from 'svelte';
|
||||
import type { GPXFile } from 'gpx';
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
let tabs: HTMLDivElement;
|
||||
let buttons: HTMLButtonElement[] = [];
|
||||
let sortable: Sortable;
|
||||
@@ -27,6 +28,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
function selectAllFiles() {
|
||||
selectedFiles.update((selectedFiles) => {
|
||||
get(files).forEach((file) => {
|
||||
selectedFiles.add(file);
|
||||
});
|
||||
return selectedFiles;
|
||||
});
|
||||
}
|
||||
|
||||
function deselectFile(file: GPXFile) {
|
||||
selectedFiles.update((selectedFiles) => {
|
||||
selectedFiles.delete(file);
|
||||
@@ -81,6 +91,12 @@
|
||||
Sortable.utils.select(buttons[index]);
|
||||
addSelectFile(file);
|
||||
},
|
||||
selectAllFiles: () => {
|
||||
$files.forEach((file, index) => {
|
||||
Sortable.utils.select(buttons[index]);
|
||||
});
|
||||
selectAllFiles();
|
||||
},
|
||||
removeSelect: (file: GPXFile) => {
|
||||
const index = $files.indexOf(file);
|
||||
Sortable.utils.deselect(buttons[index]);
|
||||
|
@@ -22,7 +22,8 @@
|
||||
exportSelectedFiles,
|
||||
removeAllFiles,
|
||||
removeSelectedFiles,
|
||||
triggerFileInput
|
||||
triggerFileInput,
|
||||
selectFiles
|
||||
} from '$lib/stores';
|
||||
|
||||
let distanceUnits = 'metric';
|
||||
@@ -170,6 +171,9 @@
|
||||
removeSelectedFiles();
|
||||
}
|
||||
e.preventDefault();
|
||||
} else if (e.key === 'a' && (e.metaKey || e.ctrlKey)) {
|
||||
$selectFiles.selectAllFiles();
|
||||
e.preventDefault();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
@@ -7,7 +7,7 @@ export const map = writable<mapboxgl.Map | null>(null);
|
||||
export const files = writable<GPXFile[]>([]);
|
||||
export const fileOrder = writable<GPXFile[]>([]);
|
||||
export const selectedFiles = writable<Set<GPXFile>>(new Set());
|
||||
export const selectFiles = writable<{ [key: string]: (file: GPXFile) => void }>({});
|
||||
export const selectFiles = writable<{ [key: string]: (file?: GPXFile) => void }>({});
|
||||
|
||||
export function triggerFileInput() {
|
||||
const input = document.createElement('input');
|
||||
|
Reference in New Issue
Block a user