fix: use smart default for displayField based on entityType
When displayField is omitted in award definitions, the backend now selects the appropriate default field based on the entityType: - dxcc → entity (country name) - state → state - grid → grid (4-character) - callsign → callsign Previously, it used a fixed fallback order that prioritized entity over other fields, causing grid-based awards to show DXCC names. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -896,7 +896,19 @@ export async function getAwardEntityBreakdown(userId, awardId) {
|
|||||||
}
|
}
|
||||||
displayName = String(rawValue || entity);
|
displayName = String(rawValue || entity);
|
||||||
} else {
|
} else {
|
||||||
displayName = qso.entity || qso.state || qso.grid || qso.callsign || String(entity);
|
// Smart default based on entityType when displayField is not specified
|
||||||
|
const defaultDisplayField = {
|
||||||
|
'dxcc': 'entity',
|
||||||
|
'state': 'state',
|
||||||
|
'grid': 'grid',
|
||||||
|
'callsign': 'callsign'
|
||||||
|
}[rules.entityType] || 'entity';
|
||||||
|
|
||||||
|
let rawValue = qso[defaultDisplayField];
|
||||||
|
if (defaultDisplayField === 'grid' && rawValue && rawValue.length > 4) {
|
||||||
|
rawValue = rawValue.substring(0, 4);
|
||||||
|
}
|
||||||
|
displayName = String(rawValue || entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!slotMap.has(slotKey)) {
|
if (!slotMap.has(slotKey)) {
|
||||||
|
|||||||
@@ -804,7 +804,7 @@
|
|||||||
bind:value={formData.rules.displayField}
|
bind:value={formData.rules.displayField}
|
||||||
placeholder="e.g., entity, state, grid"
|
placeholder="e.g., entity, state, grid"
|
||||||
/>
|
/>
|
||||||
<small>Field to display as entity name (defaults to entity value)</small>
|
<small>Field to display as entity name (defaults based on entityType)</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -197,15 +197,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if displayField matches the default for the entity type
|
// Check if displayField matches the default for the entity type
|
||||||
if (rules.entityType && rules.displayField) {
|
if (rules.entityType) {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
'dxcc': 'entity',
|
'dxcc': 'entity',
|
||||||
'state': 'state',
|
'state': 'state',
|
||||||
'grid': 'grid',
|
'grid': 'grid',
|
||||||
'callsign': 'callsign'
|
'callsign': 'callsign'
|
||||||
};
|
};
|
||||||
if (defaults[rules.entityType] === rules.displayField) {
|
const defaultField = defaults[rules.entityType];
|
||||||
info.push(`displayField="${rules.displayField}" is the default for entityType="${rules.entityType}". It can be omitted.`);
|
|
||||||
|
if (rules.displayField) {
|
||||||
|
if (defaultField === rules.displayField) {
|
||||||
|
info.push(`displayField="${rules.displayField}" is the default for entityType="${rules.entityType}". It can be omitted.`);
|
||||||
|
}
|
||||||
|
} else if (defaultField) {
|
||||||
|
info.push(`displayField will default to "${defaultField}" for entityType="${rules.entityType}".`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -829,7 +829,7 @@
|
|||||||
bind:value={formData.rules.displayField}
|
bind:value={formData.rules.displayField}
|
||||||
placeholder="e.g., entity, state, grid"
|
placeholder="e.g., entity, state, grid"
|
||||||
/>
|
/>
|
||||||
<small>Field to display as entity name (defaults to entity value)</small>
|
<small>Field to display as entity name (defaults based on entityType)</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
Reference in New Issue
Block a user