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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user