mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-01 08:12:32 +00:00
avoid selecting other file when routing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { GPXFile } from "gpx";
|
||||
import { map, selectFiles } from "$lib/stores";
|
||||
import { map, selectFiles, currentTool, Tool } from "$lib/stores";
|
||||
import { get, type Writable } from "svelte/store";
|
||||
import type mapboxgl from "mapbox-gl";
|
||||
|
||||
@@ -122,6 +122,9 @@ export class GPXMapLayer {
|
||||
}
|
||||
|
||||
selectOnClick(e: any) {
|
||||
if (get(currentTool) === Tool.ROUTING) {
|
||||
return;
|
||||
}
|
||||
if (e.originalEvent.shiftKey) {
|
||||
get(selectFiles).addSelect(get(this.file));
|
||||
} else {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { reverseSelectedFiles } from '$lib/stores';
|
||||
import { currentTool, reverseSelectedFiles, Tool } from '$lib/stores';
|
||||
import Routing from './routing/Routing.svelte';
|
||||
import ToolbarItem from './ToolbarItem.svelte';
|
||||
import {
|
||||
@@ -17,14 +17,12 @@
|
||||
|
||||
import { _ } from 'svelte-i18n';
|
||||
|
||||
let currentTool: string | null = null;
|
||||
|
||||
function getToggleTool(tool: string) {
|
||||
function getToggleTool(tool: Tool) {
|
||||
return () => toggleTool(tool);
|
||||
}
|
||||
|
||||
function toggleTool(tool: string) {
|
||||
currentTool = currentTool === tool ? null : tool;
|
||||
function toggleTool(tool: Tool) {
|
||||
currentTool.update((current) => (current === tool ? null : tool));
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -33,7 +31,7 @@
|
||||
<div
|
||||
class="h-fit flex flex-col p-1 gap-1 bg-background rounded-md pointer-events-auto shadow-md border"
|
||||
>
|
||||
<ToolbarItem on:click={getToggleTool('routing')}>
|
||||
<ToolbarItem on:click={getToggleTool(Tool.ROUTING)}>
|
||||
<Pencil slot="icon" size="18" />
|
||||
<span slot="tooltip">{$_('toolbar.routing.tooltip')}</span>
|
||||
</ToolbarItem>
|
||||
@@ -74,7 +72,7 @@
|
||||
<span slot="tooltip">{$_('toolbar.structure_tooltip')}</span>
|
||||
</ToolbarItem>
|
||||
</div>
|
||||
{#if currentTool == 'routing'}
|
||||
{#if $currentTool === Tool.ROUTING}
|
||||
<Routing />
|
||||
{/if}
|
||||
</div>
|
||||
|
@@ -13,6 +13,10 @@ export const settings = writable<{ [key: string]: any }>({
|
||||
velocityUnits: 'speed',
|
||||
temperatureUnits: 'celsius',
|
||||
});
|
||||
export enum Tool {
|
||||
ROUTING
|
||||
}
|
||||
export const currentTool = writable<Tool | null>(null);
|
||||
|
||||
export function getFileStore(file: GPXFile): Writable<GPXFile> {
|
||||
return get(files).find(store => get(store) === file) ?? addFile(file);
|
||||
|
Reference in New Issue
Block a user