Improve spool ID search and AMS assignment (issue #2978) (#2998)

This commit is contained in:
Peer Drescher
2026-09-28 16:42:38 +02:00
committed by GitHub
parent a06bb05624
commit 632930f02a
27 changed files with 781 additions and 190 deletions
+11 -2
View File
@@ -6,8 +6,17 @@ import { resolveSpoolColorName } from './colors';
* Case-insensitive. Empty query always returns true.
*/
export function spoolMatchesQuery(spool: InventorySpool, query: string): boolean {
if (!query) return true;
const q = query.toLowerCase();
const q = query.trim().toLowerCase();
if (!q) return true;
// A hash-prefixed number is an explicit spool ID lookup. Keep plain numeric
// searches backwards-compatible ("3" can still match #3, #13, #30, ...),
// while "#3" selects only the physical spool whose label says #3.
const exactIdQuery = q.match(/^#(\d+)$/);
if (exactIdQuery) {
return spool.id === Number(exactIdQuery[1]);
}
return (
String(spool.id).includes(q) ||
spool.material.toLowerCase().includes(q) ||