adds search to trail edit
This commit is contained in:
@@ -94,6 +94,25 @@
|
|||||||
border-color: rgba(var(--primary)) transparent rgba(var(--primary)) transparent;
|
border-color: rgba(var(--primary)) transparent rgba(var(--primary)) transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spinner-light:after {
|
||||||
|
border: 6px solid #fff;
|
||||||
|
border-color: #fff transparent #fff transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-small {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
display: grid;
|
||||||
|
align-content: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-small:after {
|
||||||
|
border-width: 2px;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes spinner {
|
@keyframes spinner {
|
||||||
0% {
|
0% {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Bearbeiten",
|
"edit": "Bearbeiten",
|
||||||
"edit-entry": "Eintrag bearbeiten",
|
"edit-entry": "Eintrag bearbeiten",
|
||||||
"edit-list": "Liste bearbeiten",
|
"edit-list": "Liste bearbeiten",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Wegpunkt bearbeiten",
|
"edit-waypoint": "Wegpunkt bearbeiten",
|
||||||
"edited": "bearbeitet",
|
"edited": "bearbeitet",
|
||||||
"elevation-gain": "Höhenunterschied (aufw.)",
|
"elevation-gain": "Höhenunterschied (aufw.)",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Geschwindigkeit",
|
"speed": "Geschwindigkeit",
|
||||||
"statistics": "Statistiken",
|
"statistics": "Statistiken",
|
||||||
"stop-drawing": "Zeichnen beenden",
|
"stop-drawing": "Zeichnen beenden",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Gipfelbuch",
|
"summit-book": "Gipfelbuch",
|
||||||
"table": "Tabelle",
|
"table": "Tabelle",
|
||||||
"text": "Text",
|
"text": "Text",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Einheiten",
|
"units": "Einheiten",
|
||||||
"upload-file": "Datei hochladen",
|
"upload-file": "Datei hochladen",
|
||||||
"upload-gpx": "GPX hochladen",
|
"upload-gpx": "GPX hochladen",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "hochgeladen",
|
"uploaded": "hochgeladen",
|
||||||
"username": "Nutzername",
|
"username": "Nutzername",
|
||||||
"view": "Ansehen",
|
"view": "Ansehen",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"edit-entry": "Edit Entry",
|
"edit-entry": "Edit Entry",
|
||||||
"edit-list": "Edit List",
|
"edit-list": "Edit List",
|
||||||
|
"edit-route": "Edit route",
|
||||||
"edit-waypoint": "Edit Waypoint",
|
"edit-waypoint": "Edit Waypoint",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "Elevation Gain",
|
"elevation-gain": "Elevation Gain",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Speed",
|
"speed": "Speed",
|
||||||
"statistics": "Statistics",
|
"statistics": "Statistics",
|
||||||
"stop-drawing": "Stop drawing",
|
"stop-drawing": "Stop drawing",
|
||||||
|
"stop-editing": "Stop editing",
|
||||||
"summit-book": "Summit Book",
|
"summit-book": "Summit Book",
|
||||||
"table": "Table",
|
"table": "Table",
|
||||||
"text": "Text",
|
"text": "Text",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Units",
|
"units": "Units",
|
||||||
"upload-file": "Upload file",
|
"upload-file": "Upload file",
|
||||||
"upload-gpx": "Upload GPX",
|
"upload-gpx": "Upload GPX",
|
||||||
|
"upload-new-file": "Upload new file",
|
||||||
"uploaded": "uploaded",
|
"uploaded": "uploaded",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
"view": "View",
|
"view": "View",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Editar",
|
"edit": "Editar",
|
||||||
"edit-entry": "Editar entrada",
|
"edit-entry": "Editar entrada",
|
||||||
"edit-list": "Editar Lista",
|
"edit-list": "Editar Lista",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Editar Punto de Interés",
|
"edit-waypoint": "Editar Punto de Interés",
|
||||||
"edited": "editado",
|
"edited": "editado",
|
||||||
"elevation-gain": "Ascenso",
|
"elevation-gain": "Ascenso",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Velocidad",
|
"speed": "Velocidad",
|
||||||
"statistics": "Estadísticas",
|
"statistics": "Estadísticas",
|
||||||
"stop-drawing": "Parar de diseñar",
|
"stop-drawing": "Parar de diseñar",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Libro de ascensos",
|
"summit-book": "Libro de ascensos",
|
||||||
"table": "Tabla",
|
"table": "Tabla",
|
||||||
"text": "Texto",
|
"text": "Texto",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Unidades",
|
"units": "Unidades",
|
||||||
"upload-file": "Cargar archivo",
|
"upload-file": "Cargar archivo",
|
||||||
"upload-gpx": "Cargar GPX",
|
"upload-gpx": "Cargar GPX",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "cargado",
|
"uploaded": "cargado",
|
||||||
"username": "Nombre de usuario",
|
"username": "Nombre de usuario",
|
||||||
"view": "Ver",
|
"view": "Ver",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Editer",
|
"edit": "Editer",
|
||||||
"edit-entry": "Éditer une entrée",
|
"edit-entry": "Éditer une entrée",
|
||||||
"edit-list": "Éditer la liste",
|
"edit-list": "Éditer la liste",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Éditer le point de repère",
|
"edit-waypoint": "Éditer le point de repère",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "Dénivelé positif",
|
"elevation-gain": "Dénivelé positif",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Vitesse",
|
"speed": "Vitesse",
|
||||||
"statistics": "Statistics",
|
"statistics": "Statistics",
|
||||||
"stop-drawing": "Arrêter de tracer",
|
"stop-drawing": "Arrêter de tracer",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Liste des ascensions",
|
"summit-book": "Liste des ascensions",
|
||||||
"table": "Tableau",
|
"table": "Tableau",
|
||||||
"text": "Texte",
|
"text": "Texte",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Unités",
|
"units": "Unités",
|
||||||
"upload-file": "Importer un fichier",
|
"upload-file": "Importer un fichier",
|
||||||
"upload-gpx": "Envoyer un GPX",
|
"upload-gpx": "Envoyer un GPX",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "téléchargé",
|
"uploaded": "téléchargé",
|
||||||
"username": "Nom d'utilisateur",
|
"username": "Nom d'utilisateur",
|
||||||
"view": "Afficher",
|
"view": "Afficher",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Szerkesztés",
|
"edit": "Szerkesztés",
|
||||||
"edit-entry": "Bejegyzés szerkesztése",
|
"edit-entry": "Bejegyzés szerkesztése",
|
||||||
"edit-list": "Lista szerkesztése",
|
"edit-list": "Lista szerkesztése",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Útvonalpont szerkesztése",
|
"edit-waypoint": "Útvonalpont szerkesztése",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "Magasságnövekedés",
|
"elevation-gain": "Magasságnövekedés",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Speed",
|
"speed": "Speed",
|
||||||
"statistics": "Statistics",
|
"statistics": "Statistics",
|
||||||
"stop-drawing": "Stop drawing",
|
"stop-drawing": "Stop drawing",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Csúcspont könyv",
|
"summit-book": "Csúcspont könyv",
|
||||||
"table": "Táblázat",
|
"table": "Táblázat",
|
||||||
"text": "Szöveg",
|
"text": "Szöveg",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Mértékegységek",
|
"units": "Mértékegységek",
|
||||||
"upload-file": "Fájl feltöltése",
|
"upload-file": "Fájl feltöltése",
|
||||||
"upload-gpx": "GPX feltöltése",
|
"upload-gpx": "GPX feltöltése",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "uploaded",
|
"uploaded": "uploaded",
|
||||||
"username": "Felhasználónév",
|
"username": "Felhasználónév",
|
||||||
"view": "View",
|
"view": "View",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Modifica",
|
"edit": "Modifica",
|
||||||
"edit-entry": "Modifica voce",
|
"edit-entry": "Modifica voce",
|
||||||
"edit-list": "Modifica lista",
|
"edit-list": "Modifica lista",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Modifica waypoint",
|
"edit-waypoint": "Modifica waypoint",
|
||||||
"edited": "modificato",
|
"edited": "modificato",
|
||||||
"elevation-gain": "Guadagno di quota",
|
"elevation-gain": "Guadagno di quota",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Velocità",
|
"speed": "Velocità",
|
||||||
"statistics": "Statistiche",
|
"statistics": "Statistiche",
|
||||||
"stop-drawing": "Smettere di disegnare",
|
"stop-drawing": "Smettere di disegnare",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Libro di vetta",
|
"summit-book": "Libro di vetta",
|
||||||
"table": "Tavolo",
|
"table": "Tavolo",
|
||||||
"text": "Testo",
|
"text": "Testo",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Unità",
|
"units": "Unità",
|
||||||
"upload-file": "Carica file",
|
"upload-file": "Carica file",
|
||||||
"upload-gpx": "Carica file GPX",
|
"upload-gpx": "Carica file GPX",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "caricato",
|
"uploaded": "caricato",
|
||||||
"username": "Nome utente",
|
"username": "Nome utente",
|
||||||
"view": "Visualizza",
|
"view": "Visualizza",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Bewerken",
|
"edit": "Bewerken",
|
||||||
"edit-entry": "Item bewerken",
|
"edit-entry": "Item bewerken",
|
||||||
"edit-list": "Lijst aanpassen",
|
"edit-list": "Lijst aanpassen",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Routepunt aanpassen",
|
"edit-waypoint": "Routepunt aanpassen",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "Hoogteverschil",
|
"elevation-gain": "Hoogteverschil",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Speed",
|
"speed": "Speed",
|
||||||
"statistics": "Statistics",
|
"statistics": "Statistics",
|
||||||
"stop-drawing": "Stop drawing",
|
"stop-drawing": "Stop drawing",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Bergtopboek",
|
"summit-book": "Bergtopboek",
|
||||||
"table": "Tabel",
|
"table": "Tabel",
|
||||||
"text": "Tekst",
|
"text": "Tekst",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Eenheden",
|
"units": "Eenheden",
|
||||||
"upload-file": "Bestand uploaden",
|
"upload-file": "Bestand uploaden",
|
||||||
"upload-gpx": "GPX-bestand uploaden",
|
"upload-gpx": "GPX-bestand uploaden",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "uploaded",
|
"uploaded": "uploaded",
|
||||||
"username": "Gebruikersnaam",
|
"username": "Gebruikersnaam",
|
||||||
"view": "View",
|
"view": "View",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Edytuj",
|
"edit": "Edytuj",
|
||||||
"edit-entry": "Edytuj pozycję",
|
"edit-entry": "Edytuj pozycję",
|
||||||
"edit-list": "Edytuj Listę",
|
"edit-list": "Edytuj Listę",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Edytuj Punkt",
|
"edit-waypoint": "Edytuj Punkt",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "Przyrost wysokości",
|
"elevation-gain": "Przyrost wysokości",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Prędkość",
|
"speed": "Prędkość",
|
||||||
"statistics": "Statystyki",
|
"statistics": "Statystyki",
|
||||||
"stop-drawing": "Przestań rysować",
|
"stop-drawing": "Przestań rysować",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Logbook",
|
"summit-book": "Logbook",
|
||||||
"table": "Tabela",
|
"table": "Tabela",
|
||||||
"text": "Tekst",
|
"text": "Tekst",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Jednostki",
|
"units": "Jednostki",
|
||||||
"upload-file": "Przesyłanie pliku",
|
"upload-file": "Przesyłanie pliku",
|
||||||
"upload-gpx": "Importuj GPX",
|
"upload-gpx": "Importuj GPX",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "wgrany",
|
"uploaded": "wgrany",
|
||||||
"username": "Nazwa Użytkownika",
|
"username": "Nazwa Użytkownika",
|
||||||
"view": "Widok",
|
"view": "Widok",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "Editar",
|
"edit": "Editar",
|
||||||
"edit-entry": "Editar entrada",
|
"edit-entry": "Editar entrada",
|
||||||
"edit-list": "Editar lista",
|
"edit-list": "Editar lista",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "Editar ponto de passagem",
|
"edit-waypoint": "Editar ponto de passagem",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "Ganho de elevação",
|
"elevation-gain": "Ganho de elevação",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "Velocidade",
|
"speed": "Velocidade",
|
||||||
"statistics": "Statistics",
|
"statistics": "Statistics",
|
||||||
"stop-drawing": "Parar desenho",
|
"stop-drawing": "Parar desenho",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "Livro da cimeira",
|
"summit-book": "Livro da cimeira",
|
||||||
"table": "Tabela",
|
"table": "Tabela",
|
||||||
"text": "Texto",
|
"text": "Texto",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "Unidades",
|
"units": "Unidades",
|
||||||
"upload-file": "Subir arquivo",
|
"upload-file": "Subir arquivo",
|
||||||
"upload-gpx": "Carregar GPX",
|
"upload-gpx": "Carregar GPX",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "carregado",
|
"uploaded": "carregado",
|
||||||
"username": "Nome de utilizador",
|
"username": "Nome de utilizador",
|
||||||
"view": "Ver",
|
"view": "Ver",
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
"edit": "编辑",
|
"edit": "编辑",
|
||||||
"edit-entry": "编辑日程",
|
"edit-entry": "编辑日程",
|
||||||
"edit-list": "编辑列表",
|
"edit-list": "编辑列表",
|
||||||
|
"edit-route": "",
|
||||||
"edit-waypoint": "编辑坐标",
|
"edit-waypoint": "编辑坐标",
|
||||||
"edited": "edited",
|
"edited": "edited",
|
||||||
"elevation-gain": "上升海拔",
|
"elevation-gain": "上升海拔",
|
||||||
@@ -259,6 +260,7 @@
|
|||||||
"speed": "速度",
|
"speed": "速度",
|
||||||
"statistics": "Statistics",
|
"statistics": "Statistics",
|
||||||
"stop-drawing": "停止绘制",
|
"stop-drawing": "停止绘制",
|
||||||
|
"stop-editing": "",
|
||||||
"summit-book": "详细日程",
|
"summit-book": "详细日程",
|
||||||
"table": "表格",
|
"table": "表格",
|
||||||
"text": "文本",
|
"text": "文本",
|
||||||
@@ -270,6 +272,7 @@
|
|||||||
"units": "单位",
|
"units": "单位",
|
||||||
"upload-file": "上传文件",
|
"upload-file": "上传文件",
|
||||||
"upload-gpx": "上传 GPX",
|
"upload-gpx": "上传 GPX",
|
||||||
|
"upload-new-file": "",
|
||||||
"uploaded": "已上传",
|
"uploaded": "已上传",
|
||||||
"username": "用户名",
|
"username": "用户名",
|
||||||
"view": "查看",
|
"view": "查看",
|
||||||
|
|||||||
@@ -70,6 +70,10 @@
|
|||||||
import { backInOut } from "svelte/easing";
|
import { backInOut } from "svelte/easing";
|
||||||
import { scale } from "svelte/transition";
|
import { scale } from "svelte/transition";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import Search, {
|
||||||
|
type SearchItem,
|
||||||
|
} from "$lib/components/base/search.svelte";
|
||||||
|
import { country_codes } from "$lib/util/country_code_util.js";
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -96,6 +100,8 @@
|
|||||||
let overwriteGPX = false;
|
let overwriteGPX = false;
|
||||||
let draggingMarker = false;
|
let draggingMarker = false;
|
||||||
|
|
||||||
|
let searchDropdownItems: SearchItem[] = [];
|
||||||
|
|
||||||
const ClientTrailCreateSchema = TrailCreateSchema.extend({
|
const ClientTrailCreateSchema = TrailCreateSchema.extend({
|
||||||
expand: z
|
expand: z
|
||||||
.object({
|
.object({
|
||||||
@@ -523,6 +529,12 @@
|
|||||||
addAnchor(e.lngLat.lat, e.lngLat.lng, anchors.length);
|
addAnchor(e.lngLat.lat, e.lngLat.lng, anchors.length);
|
||||||
} else {
|
} else {
|
||||||
const previousAnchor = anchors[anchorCount - 1];
|
const previousAnchor = anchors[anchorCount - 1];
|
||||||
|
const anchor = addAnchor(
|
||||||
|
e.lngLat.lat,
|
||||||
|
e.lngLat.lng,
|
||||||
|
anchors.length,
|
||||||
|
);
|
||||||
|
const markerText = startAnchorLoading(anchor);
|
||||||
try {
|
try {
|
||||||
const routeWaypoints = await calculateRouteBetween(
|
const routeWaypoints = await calculateRouteBetween(
|
||||||
previousAnchor.lat,
|
previousAnchor.lat,
|
||||||
@@ -533,7 +545,6 @@
|
|||||||
autoRouting,
|
autoRouting,
|
||||||
);
|
);
|
||||||
insertIntoRoute(routeWaypoints);
|
insertIntoRoute(routeWaypoints);
|
||||||
addAnchor(e.lngLat.lat, e.lngLat.lng, anchors.length);
|
|
||||||
updateTrailWithRouteData();
|
updateTrailWithRouteData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -542,6 +553,8 @@
|
|||||||
icon: "close",
|
icon: "close",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
stopAnchorLoading(anchor, markerText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,14 +580,16 @@
|
|||||||
(e) => {
|
(e) => {
|
||||||
draggingMarker = true;
|
draggingMarker = true;
|
||||||
},
|
},
|
||||||
(_) => {
|
async (_) => {
|
||||||
if (!drawingActive) {
|
if (!drawingActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const position = marker.getLngLat();
|
const position = marker.getLngLat();
|
||||||
anchor.lat = position.lat;
|
anchor.lat = position.lat;
|
||||||
anchor.lon = position.lng;
|
anchor.lon = position.lng;
|
||||||
recalculateRoute(anchors.findIndex((a) => a.id == anchor.id));
|
await recalculateRoute(
|
||||||
|
anchors.findIndex((a) => a.id == anchor.id),
|
||||||
|
);
|
||||||
draggingMarker = false;
|
draggingMarker = false;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -587,7 +602,32 @@
|
|||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAnchor(anchorIndex: number) {
|
function startAnchorLoading(anchor: ValhallaAnchor) {
|
||||||
|
const markerIcon = anchor.marker?.getElement();
|
||||||
|
if (!markerIcon) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
markerIcon.classList.add("spinner", "spinner-light", "spinner-small");
|
||||||
|
const savedMarkerNumber = markerIcon.textContent;
|
||||||
|
markerIcon.textContent = "";
|
||||||
|
|
||||||
|
return savedMarkerNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopAnchorLoading(anchor: ValhallaAnchor, index: string | null) {
|
||||||
|
const markerIcon = anchor.marker?.getElement();
|
||||||
|
if (!markerIcon || !index) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
markerIcon.classList.remove(
|
||||||
|
"spinner",
|
||||||
|
"spinner-light",
|
||||||
|
"spinner-small",
|
||||||
|
);
|
||||||
|
markerIcon.textContent = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeAnchor(anchorIndex: number) {
|
||||||
if (!drawingActive) {
|
if (!drawingActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -610,11 +650,13 @@
|
|||||||
updateTrailWithRouteData();
|
updateTrailWithRouteData();
|
||||||
} else {
|
} else {
|
||||||
deleteFromRoute(anchorIndex - 1);
|
deleteFromRoute(anchorIndex - 1);
|
||||||
recalculateRoute(anchorIndex);
|
await recalculateRoute(anchorIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function recalculateRoute(anchorIndex: number) {
|
async function recalculateRoute(anchorIndex: number) {
|
||||||
|
const markerText = startAnchorLoading(anchors[anchorIndex]);
|
||||||
|
|
||||||
const anchor = anchors[anchorIndex];
|
const anchor = anchors[anchorIndex];
|
||||||
if (!anchor) {
|
if (!anchor) {
|
||||||
return;
|
return;
|
||||||
@@ -661,6 +703,8 @@
|
|||||||
icon: "close",
|
icon: "close",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
stopAnchorLoading(anchors[anchorIndex], markerText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,6 +720,8 @@
|
|||||||
data.event.lngLat.lng,
|
data.event.lngLat.lng,
|
||||||
data.segment + 1,
|
data.segment + 1,
|
||||||
);
|
);
|
||||||
|
const markerText = startAnchorLoading(anchor);
|
||||||
|
|
||||||
for (let i = data.segment + 2; i < anchors.length; i++) {
|
for (let i = data.segment + 2; i < anchors.length; i++) {
|
||||||
const anchor = anchors[i];
|
const anchor = anchors[i];
|
||||||
const markerIcon = anchor.marker?.getElement();
|
const markerIcon = anchor.marker?.getElement();
|
||||||
@@ -716,6 +762,8 @@
|
|||||||
icon: "close",
|
icon: "close",
|
||||||
type: "error",
|
type: "error",
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
stopAnchorLoading(anchor, markerText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,6 +783,30 @@
|
|||||||
function updateTrailOnMap() {
|
function updateTrailOnMap() {
|
||||||
mapTrail = [$formData as Trail];
|
mapTrail = [$formData as Trail];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSearchClick(item: SearchItem) {
|
||||||
|
map.flyTo({
|
||||||
|
center: [item.value._geo.lng, item.value._geo.lat],
|
||||||
|
zoom: 13,
|
||||||
|
animate: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchCities(q: string) {
|
||||||
|
const r = await fetch("/api/v1/search/cities500", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ q: q, options: { limit: 5 } }),
|
||||||
|
});
|
||||||
|
const result = await r.json();
|
||||||
|
searchDropdownItems = result.hits.map((h: Record<string, any>) => ({
|
||||||
|
text: h.name,
|
||||||
|
description: `${h.division ? `${h.division} | ` : ""}${
|
||||||
|
country_codes[h["country code"] as keyof typeof country_codes]
|
||||||
|
}`,
|
||||||
|
value: h,
|
||||||
|
icon: "city",
|
||||||
|
}));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -750,12 +822,22 @@
|
|||||||
class="overflow-y-auto overflow-x-hidden flex flex-col gap-4 px-8 order-1 md:order-none mt-8 md:mt-0"
|
class="overflow-y-auto overflow-x-hidden flex flex-col gap-4 px-8 order-1 md:order-none mt-8 md:mt-0"
|
||||||
use:form
|
use:form
|
||||||
>
|
>
|
||||||
|
<Search
|
||||||
|
on:update={(e) => searchCities(e.detail)}
|
||||||
|
on:click={(e) => handleSearchClick(e.detail)}
|
||||||
|
placeholder="{$_('search-cities')}..."
|
||||||
|
items={searchDropdownItems}
|
||||||
|
></Search>
|
||||||
|
<hr class="border-input-border" />
|
||||||
<h3 class="text-xl font-semibold">{$_("pick-a-trail")}</h3>
|
<h3 class="text-xl font-semibold">{$_("pick-a-trail")}</h3>
|
||||||
<Button
|
<Button
|
||||||
primary={true}
|
primary={true}
|
||||||
type="button"
|
type="button"
|
||||||
disabled={drawingActive}
|
disabled={drawingActive}
|
||||||
on:click={openFileBrowser}>{$_("upload-file")}</Button
|
on:click={openFileBrowser}
|
||||||
|
>{$formData.expand?.gpx_data
|
||||||
|
? $_("upload-new-file")
|
||||||
|
: $_("upload-file")}</Button
|
||||||
>
|
>
|
||||||
{#if PUBLIC_VALHALLA_URL}
|
{#if PUBLIC_VALHALLA_URL}
|
||||||
<div class="flex gap-4 items-center w-full">
|
<div class="flex gap-4 items-center w-full">
|
||||||
@@ -768,9 +850,13 @@
|
|||||||
type="button"
|
type="button"
|
||||||
on:click={drawingActive ? stopDrawing : startDrawing}
|
on:click={drawingActive ? stopDrawing : startDrawing}
|
||||||
>
|
>
|
||||||
{drawingActive
|
{$formData.expand?.gpx_data
|
||||||
? $_("stop-drawing")
|
? drawingActive
|
||||||
: $_("draw-a-route")}</button
|
? $_("stop-editing")
|
||||||
|
: $_("edit-route")
|
||||||
|
: drawingActive
|
||||||
|
? $_("stop-drawing")
|
||||||
|
: $_("draw-a-route")}</button
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
<input
|
<input
|
||||||
|
|||||||
Reference in New Issue
Block a user