fixes multiple issues

This commit is contained in:
Christian Beutel
2024-07-24 17:45:33 +02:00
parent 0d6d034ed5
commit 75dfdb0511
5 changed files with 34 additions and 20 deletions

View File

@@ -103,22 +103,23 @@
const baseMaps: Record<string, L.TileLayer> = {
OpenStreetMaps: baseLayer,
OpenTopoMaps: topoLayer,
...($page.data.settings as Settings).tilesets?.reduce<
Record<string, string>
>((t, current) => {
...($page.data.settings as Settings)?.tilesets?.reduce< Record<string, string>>((t, current) => {
t[current.name] = L.tileLayer(current.url);
return t;
}, {}),
};
};
L.control.layers(baseMaps).addTo(map);
const layerPreference = localStorage.getItem("layer")
const layerPreference = localStorage.getItem("layer");
if (layerPreference && Object.keys(baseMaps).includes(layerPreference)) {
baseMaps[layerPreference].addTo(map!)
}else {
baseLayer.addTo(map)
if (
layerPreference &&
Object.keys(baseMaps).includes(layerPreference)
) {
baseMaps[layerPreference].addTo(map!);
} else {
baseLayer.addTo(map);
}
map!.on("baselayerchange", function (e) {

View File

@@ -54,7 +54,9 @@
]
: []),
{ text: $_("print"), value: "print", icon: "print" },
{ text: $_("add-to-list"), value: "list", icon: "bookmark" },
...(trail.author != pb.authStore.model?.id
? []
: [{ text: $_("add-to-list"), value: "list", icon: "bookmark" }]),
...(trail.author != pb.authStore.model?.id
? []
: [{ text: $_("share"), value: "share", icon: "share" }]),

View File

@@ -219,7 +219,7 @@
</h3>
</div>
</div>
{#if ($currentUser && $currentUser.id == trail.author) || trail.expand.trail_share_via_trail?.length}
{#if ($currentUser && $currentUser.id == trail.author) || trail.expand.trail_share_via_trail?.length || trail.public}
<TrailDropdown {trail} {mode}></TrailDropdown>
{/if}
</div>

View File

@@ -8,7 +8,7 @@ import Waypoint from './waypoint';
const defaultAttributes = {
version: '1.1',
creator: 'wanderer',
xmlns: 'http://www.topografix.com/GPX/1/1',
'xmlns:prod': 'http://www.topografix.com/GPX/1/1',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation':
'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'
@@ -18,7 +18,7 @@ export default class GPX {
$: {
version: string;
creator: string;
xmlns: string;
'xmlns:prod': string;
'xmlns:xsi': string;
'xsi:schemaLocation': string;
}
@@ -32,7 +32,7 @@ export default class GPX {
$?: {
version: string,
creator: string,
xmlns: string,
'xmlns:prod': string,
'xmlns:xsi': string,
'xsi:schemaLocation': string,
}
@@ -144,8 +144,10 @@ export default class GPX {
options = options || {};
options.rootName = 'gpx';
const builder = new xml2js.Builder(options), gpx = new GPX(this);
const builder = new xml2js.Builder(options)
const gpx = new GPX(this);
allDatesToISOString(gpx);
return builder.buildObject(gpx);
return builder.buildObject(gpx).replace('xmlns:prod', 'xmlns');
}
}

View File

@@ -51,7 +51,13 @@
formatElevation,
formatTimeHHMM,
} from "$lib/util/format_util";
import { fromFIT, fromKML, fromTCX, gpx2trail, isFITFile } from "$lib/util/gpx_util";
import {
fromFIT,
fromKML,
fromTCX,
gpx2trail,
isFITFile,
} from "$lib/util/gpx_util";
import {
createAnchorMarker,
createMarkerFromWaypoint,
@@ -113,7 +119,10 @@
const { form, errors, handleChange, handleSubmit } = createForm<Trail>({
initialValues: {
...data.trail,
category: $page.data.settings?.category || $categories[0].id,
category:
data.trail.category ||
$page.data.settings?.category ||
$categories[0].id,
},
validationSchema: trailSchema,
onError: (errors) => {
@@ -189,7 +198,7 @@
show_toast({
type: "success",
icon: "check",
text: $_('trail-saved-successfully'),
text: $_("trail-saved-successfully"),
});
} catch (e) {
console.error(e);
@@ -197,7 +206,7 @@
show_toast({
type: "error",
icon: "close",
text: $_('error-saving-trail'),
text: $_("error-saving-trail"),
});
} finally {
loading = false;