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