From dfa139c543f26f4f4fce912a656839518d12a0b2 Mon Sep 17 00:00:00 2001 From: Florian Zumpe Date: Sun, 27 Sep 2026 20:51:47 +0200 Subject: [PATCH] minor graphics update --- public/css/editor.css | 12 ++++++++++-- public/images/icons/route-management.svg | 5 +++++ public/index.html | 4 +++- public/js/editor-ui.js | 16 ++++++++-------- test/editor-ui.test.js | 19 +++++++++++++++++-- 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 public/images/icons/route-management.svg diff --git a/public/css/editor.css b/public/css/editor.css index 500032d..a9e8fed 100644 --- a/public/css/editor.css +++ b/public/css/editor.css @@ -142,7 +142,7 @@ .route-control-actions { display: grid; - grid-template-columns: 1fr; + grid-template-columns: auto minmax(0, 1fr); gap: .5rem; margin-top: .85rem; padding-top: .75rem; @@ -171,7 +171,15 @@ align-items: center; display: inline-flex; justify-content: center; - font-weight: 700; + min-height: 2.75rem; + min-width: 2.75rem; + padding: .5rem; +} + +.editor-button-icon { + display: block; + height: 1.65rem; + width: 1.65rem; } .editor-media-actions { diff --git a/public/images/icons/route-management.svg b/public/images/icons/route-management.svg new file mode 100644 index 0000000..6f4e871 --- /dev/null +++ b/public/images/icons/route-management.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/index.html b/public/index.html index 40d6283..b6b7769 100644 --- a/public/index.html +++ b/public/index.html @@ -140,7 +140,9 @@
- +
diff --git a/public/js/editor-ui.js b/public/js/editor-ui.js index 68e8c1f..b2af412 100644 --- a/public/js/editor-ui.js +++ b/public/js/editor-ui.js @@ -336,7 +336,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {}; const actions = document.createElement('div'); actions.className = classes.iconRow; actions.appendChild(iconButton('Strecke bearbeiten', '✎', 'edit-route')); - actions.appendChild(iconButton('Strecke löschen', '×', 'delete-route', false, true)); + if (routeSource(route) === 'local') { + actions.appendChild(iconButton('Strecke löschen', '×', 'delete-route', false, true)); + } item.append(label, actions); return item; } @@ -1184,13 +1186,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {}; async function deleteRouteFromList(route) { const id = routeId(route); - if (!id) return; + if (!id || routeSource(route) !== 'local') return; - if (routeSource(route) === 'local') { - ns.LocalRoutes.remove(id); - } else { - await sendDelete(`/routes/${encodeURIComponent(id)}`); - } + ns.LocalRoutes.remove(id); if (routeId(state.currentRoute) === id && state.currentSource === routeSource(route)) { state.currentRoute = null; @@ -1214,7 +1212,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {}; await loadRoute(route); return; } - if (action === 'delete-route') await deleteRouteFromList(route); + if (action === 'delete-route' && routeSource(route) === 'local') { + await deleteRouteFromList(route); + } } async function deletePoiFromList(poi) { diff --git a/test/editor-ui.test.js b/test/editor-ui.test.js index 0b7ec1b..9d01b26 100644 --- a/test/editor-ui.test.js +++ b/test/editor-ui.test.js @@ -19,7 +19,8 @@ test('editor markup and source describe local draft creation instead of immediat const css = await read('public/css/editor.css'); const ui = await read('public/js/editor-ui.js'); - assert.match(html, /id="editor-button"/); + assert.match(html, /id="editor-button"[^>]+aria-label="Streckenverwaltung öffnen"/); + assert.match(html, /class="editor-button-icon"[^>]+src="images\/icons\/route-management\.svg"[^>]+alt=""/); assert.match(html, /]+type="button"[^>]+hidden/); assert.doesNotMatch(html, /accept="video\//); assert.match(html, /ausschließlich in diesem Browser/i); + await fs.access(path.join(root, 'public/images/icons/route-management.svg')); assert.match(css, /\.editor-dialog/); assert.match(css, /\.editor-poi-list/); @@ -48,6 +50,7 @@ test('editor markup and source describe local draft creation instead of immediat assert.match(css, /\.editor-media-remove/); assert.match(css, /\.editor-danger-button/); assert.match(css, /\.editor-icon-danger/); + assert.match(css, /\.editor-button-icon/); assert.match(ui, /readJson\(['"]\/routes\?activatedOnly=true['"]\)/); assert.match(ui, /ns\.LocalRoutes\.save\(/); @@ -499,7 +502,19 @@ test('editing an activated server route uses PUT and never writes activation sta const routeList = elements.get('editor-route-list'); const serverItem = routeList.children.find(child => child.dataset.routeSource === 'server'); - const editButton = serverItem.children[1].children[0]; + const serverActions = serverItem.children[1]; + assert.equal(serverActions.children.length, 1); + assert.equal(serverActions.children[0].dataset.editorAction, 'edit-route'); + + const forgedDelete = new FakeElement('', 'button'); + forgedDelete.dataset.editorAction = 'delete-route'; + serverActions.appendChild(forgedDelete); + routeList.dispatchEvent(pointerEvent(forgedDelete)); + await tick(); + await tick(); + assert.equal(calls.some(call => call.method === 'DELETE' && call.url === '/api/routes/1'), false); + + const editButton = serverActions.children[0]; routeList.dispatchEvent(pointerEvent(editButton)); await tick(); await tick();