This commit is contained in:
+10
-6
@@ -766,11 +766,14 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
function safeGpxFilename(name) {
|
function safeGpxFilename(name) {
|
||||||
const base = text(name || 'wegwichtel-route')
|
let base = text(name || 'wegwichtel-route')
|
||||||
.normalize('NFKD')
|
.normalize('NFKD')
|
||||||
.replaceAll(/[^a-zA-Z0-9_-]+/g, '-')
|
.replaceAll(/[^a-zA-Z0-9_-]+/g, '-');
|
||||||
.replaceAll(/^-+|-+$/g, '')
|
|
||||||
.slice(0, 80);
|
while (base.startsWith('-')) base = base.slice(1);
|
||||||
|
while (base.endsWith('-')) base = base.slice(0, -1);
|
||||||
|
|
||||||
|
base = base.slice(0, 80);
|
||||||
return `${base || 'wegwichtel-route'}.gpx`;
|
return `${base || 'wegwichtel-route'}.gpx`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,17 +825,18 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
|
|||||||
const orderedPois = [...(routePackage.pois || [])]
|
const orderedPois = [...(routePackage.pois || [])]
|
||||||
.sort((left, right) => Number(left.sequence) - Number(right.sequence));
|
.sort((left, right) => Number(left.sequence) - Number(right.sequence));
|
||||||
for (const [index, poi] of orderedPois.entries()) {
|
for (const [index, poi] of orderedPois.entries()) {
|
||||||
|
const poiTitle = poi.title || `Station ${index + 1}`;
|
||||||
const poiPayload = await sendJson(`/routes/${encodeURIComponent(createdRouteId)}/pois`, 'POST', {
|
const poiPayload = await sendJson(`/routes/${encodeURIComponent(createdRouteId)}/pois`, 'POST', {
|
||||||
description: poi.description || '',
|
description: poi.description || '',
|
||||||
lat: poi.lat,
|
lat: poi.lat,
|
||||||
lon: poi.lon,
|
lon: poi.lon,
|
||||||
sequence: index,
|
sequence: index,
|
||||||
title: poi.title || `Station ${index + 1}`,
|
title: poiTitle,
|
||||||
triggerRadiusM: poi.triggerRadiusM || 25
|
triggerRadiusM: poi.triggerRadiusM || 25
|
||||||
});
|
});
|
||||||
const serverPoi = poiPayload.poi || poiPayload;
|
const serverPoi = poiPayload.poi || poiPayload;
|
||||||
const serverPoiId = poiId(serverPoi);
|
const serverPoiId = poiId(serverPoi);
|
||||||
if (!serverPoiId) throw new Error(`Für ${poi.title || `Station ${index + 1}`} wurde keine Server-POI-ID zurückgegeben.`);
|
if (!serverPoiId) throw new Error(`Für ${poiTitle} wurde keine Server-POI-ID zurückgegeben.`);
|
||||||
await uploadLocalPoiMedia(createdRouteId, serverPoiId, poi);
|
await uploadLocalPoiMedia(createdRouteId, serverPoiId, poi);
|
||||||
}
|
}
|
||||||
return createdRouteId;
|
return createdRouteId;
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ test('public editor workflow saves new route and GPX POI locally without POSTing
|
|||||||
assert.equal(local.pois[0].images.length, 1);
|
assert.equal(local.pois[0].images.length, 1);
|
||||||
assert.match(local.pois[0].images[0].dataUrl, /^data:image\/jpeg/);
|
assert.match(local.pois[0].images[0].dataUrl, /^data:image\/jpeg/);
|
||||||
|
|
||||||
|
elements.get('editor-route-name').value = '--- Neue lokale Strecke ---';
|
||||||
elements.get('editor-route-upload').dispatchEvent(pointerEvent());
|
elements.get('editor-route-upload').dispatchEvent(pointerEvent());
|
||||||
await tick();
|
await tick();
|
||||||
await tick();
|
await tick();
|
||||||
@@ -373,7 +374,9 @@ test('public editor workflow saves new route and GPX POI locally without POSTing
|
|||||||
|
|
||||||
const routeUpload = calls.find(call => call.method === 'POST' && call.url === '/api/routes');
|
const routeUpload = calls.find(call => call.method === 'POST' && call.url === '/api/routes');
|
||||||
assert.ok(routeUpload);
|
assert.ok(routeUpload);
|
||||||
assert.ok(routeUpload.body.entries.some(([name]) => name === 'gpx'));
|
const gpxUpload = routeUpload.body.entries.find(([name]) => name === 'gpx');
|
||||||
|
assert.ok(gpxUpload);
|
||||||
|
assert.equal(gpxUpload[2], 'Neue-lokale-Strecke.gpx');
|
||||||
assert.ok(calls.some(call => call.method === 'POST' && call.url === '/api/routes/22/pois'));
|
assert.ok(calls.some(call => call.method === 'POST' && call.url === '/api/routes/22/pois'));
|
||||||
assert.ok(calls.some(call => call.method === 'POST' && call.url === '/api/routes/22/pois/23/audio'));
|
assert.ok(calls.some(call => call.method === 'POST' && call.url === '/api/routes/22/pois/23/audio'));
|
||||||
assert.ok(calls.some(call => call.method === 'POST' && call.url === '/api/routes/22/pois/23/pictures'));
|
assert.ok(calls.some(call => call.method === 'POST' && call.url === '/api/routes/22/pois/23/pictures'));
|
||||||
|
|||||||
Reference in New Issue
Block a user