Add displayField configuration to award definitions

Add configurable displayField to award definitions to control what
is shown in award details instead of always using the entity value.

## Award Definitions Updated
- DXCC: displayField = 'entity' (shows country name)
- DXCC CW: displayField = 'entity' (shows country name)
- WAS: displayField = 'state' (shows state name)
- VUCC: displayField = 'grid' (shows grid square)
- RS-44: displayField = 'callsign' (shows callsign)

## Backend Changes
- Preserve displayField when normalizing award rules
- Use displayField to determine entity name in details
- Fallback logic for awards without displayField
- Add satName to entity data for better display

This fixes VUCC showing grid squares instead of country names.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 09:12:07 +01:00
parent 3b7dfd74fe
commit 052f0d13bd
11 changed files with 28 additions and 5 deletions

View File

@@ -70,6 +70,7 @@ function normalizeAwardRules(rules) {
type: 'entity',
entityType: rules.baseRule.entityType,
target: rules.baseRule.target,
displayField: rules.baseRule.displayField,
filters: rules.filters,
};
}
@@ -81,6 +82,7 @@ function normalizeAwardRules(rules) {
type: 'entity',
entityType: rules.countBy === 'qso' ? 'callsign' : 'callsign',
target: rules.target,
displayField: rules.displayField,
filters: rules.filters,
};
}
@@ -277,16 +279,27 @@ export async function getAwardEntityBreakdown(userId, awardId) {
if (!entity) continue;
if (!entityMap.has(entity)) {
// Determine what to display as the entity name
// Use displayField from award rules, or fallback to entity/type
let displayName = String(entity);
if (rules.displayField) {
displayName = String(qso[rules.displayField] || entity);
} else {
// Fallback: try entity, state, grid, callsign in order
displayName = qso.entity || qso.state || qso.grid || qso.callsign || String(entity);
}
entityMap.set(entity, {
entity,
entityId: qso.entityId,
entityName: qso.entity || qso.state || qso.grid || qso.callsign || String(entity),
entityName: displayName,
worked: false,
confirmed: false,
qsoDate: qso.qsoDate,
band: qso.band,
mode: qso.mode,
callsign: qso.callsign,
satName: qso.satName,
});
}