From 36453c8922ec753abc25855b47b832cdc2c560ed Mon Sep 17 00:00:00 2001 From: Joerg Date: Fri, 23 Jan 2026 09:27:08 +0100 Subject: [PATCH] fix: resolve stations editor reactivity issue in award admin Use Svelte stores with value/on:input instead of bind:value for stations array to properly track nested property changes. Add invisible reactivity triggers to force Svelte to track station callsign/points properties. Also update award sorting to handle numeric prefixes in numerical order (44 before 73) and update RS-44 satellite award category. Co-Authored-By: Claude --- award-definitions/sat-rs44.json | 9 +-- src/backend/services/awards.service.js | 29 +++++++++- .../src/routes/admin/awards/[id]/+page.svelte | 57 +++++++++++++++---- .../routes/admin/awards/create/+page.svelte | 56 ++++++++++++++---- 4 files changed, 122 insertions(+), 29 deletions(-) diff --git a/award-definitions/sat-rs44.json b/award-definitions/sat-rs44.json index bed903e..5817160 100644 --- a/award-definitions/sat-rs44.json +++ b/award-definitions/sat-rs44.json @@ -1,9 +1,9 @@ { "id": "sat-rs44", - "name": "RS-44 Satellite", + "name": "44 on RS-44", "description": "Work 44 QSOs on satellite RS-44", "caption": "Make 44 unique QSOs via the RS-44 satellite. Each QSO with a different callsign counts toward the total.", - "category": "custom", + "category": "satellite", "rules": { "type": "counter", "target": 44, @@ -19,5 +19,6 @@ } ] } - } -} + }, + "modeGroups": {} +} \ No newline at end of file diff --git a/src/backend/services/awards.service.js b/src/backend/services/awards.service.js index fe3925a..7d0cb66 100644 --- a/src/backend/services/awards.service.js +++ b/src/backend/services/awards.service.js @@ -30,8 +30,7 @@ function loadAwardDefinitions() { try { // Auto-discover all JSON files in the award-definitions directory const files = readdirSync(AWARD_DEFINITIONS_DIR) - .filter(f => f.endsWith('.json')) - .sort(); + .filter(f => f.endsWith('.json')); for (const file of files) { try { @@ -47,6 +46,32 @@ function loadAwardDefinitions() { logger.error('Error loading award definitions', { error: error.message }); } + // Sort by award name with numeric prefixes in numerical order + definitions.sort((a, b) => { + const nameA = a.name || ''; + const nameB = b.name || ''; + + // Extract leading numbers if present + const matchA = nameA.match(/^(\d+)/); + const matchB = nameB.match(/^(\d+)/); + + // If both start with numbers, compare numerically first + if (matchA && matchB) { + const numA = parseInt(matchA[1], 10); + const numB = parseInt(matchB[1], 10); + if (numA !== numB) { + return numA - numB; + } + // If numbers are equal, fall through to alphabetical + } + // If one starts with a number, it comes first + else if (matchA) return -1; + else if (matchB) return 1; + + // Otherwise, alphabetical comparison (case-insensitive) + return nameA.toLowerCase().localeCompare(nameB.toLowerCase()); + }); + // Cache the definitions for future calls cachedAwardDefinitions = definitions; diff --git a/src/frontend/src/routes/admin/awards/[id]/+page.svelte b/src/frontend/src/routes/admin/awards/[id]/+page.svelte index ea9b8a5..19f5e8f 100644 --- a/src/frontend/src/routes/admin/awards/[id]/+page.svelte +++ b/src/frontend/src/routes/admin/awards/[id]/+page.svelte @@ -1,10 +1,14 @@