Compare commits
3
Commits
v0.20.4
...
8538f48259
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8538f48259 | ||
|
|
0fa91c3d5f | ||
|
|
c86d331bd9 |
@@ -2452,6 +2452,14 @@ func (a *App) migrateAwardDefs() {
|
|||||||
applog.Printf("awards: %s updated from the catalog (v%d)", code, defByCode(migrated, code).Version)
|
applog.Printf("awards: %s updated from the catalog (v%d)", code, defByCode(migrated, code).Version)
|
||||||
a.reseedRefsFromCatalog(code)
|
a.reseedRefsFromCatalog(code)
|
||||||
}
|
}
|
||||||
|
// A catalog definition changed (e.g. DDFM gained the postal-code OR-rule), so
|
||||||
|
// the materialised award_refs on existing QSOs are now stale. Clear the
|
||||||
|
// one-shot backfill flag; backfillAwardRefsOnce runs later in startup and will
|
||||||
|
// re-materialise every row against the updated definitions. This makes ANY
|
||||||
|
// future catalog bump self-heal the stored columns without a manual flag bump.
|
||||||
|
if len(updated) > 0 {
|
||||||
|
_ = a.settings.Set(a.ctx, keyAwardsMaterialized, "")
|
||||||
|
}
|
||||||
// Version-gated correction of the built-in awards' Validate sources, which
|
// Version-gated correction of the built-in awards' Validate sources, which
|
||||||
// an earlier version wrongly set equal to Confirm (so VALIDATED == CONFIRMED
|
// an earlier version wrongly set equal to Confirm (so VALIDATED == CONFIRMED
|
||||||
// even for paper-QSL-only entities). Re-apply the canonical Confirm/Validate
|
// even for paper-QSL-only entities). Re-apply the canonical Confirm/Validate
|
||||||
@@ -3415,6 +3423,10 @@ func (a *App) invalidateAwardStats() {
|
|||||||
// flips qsl_rcvd flags on existing rows).
|
// flips qsl_rcvd flags on existing rows).
|
||||||
func (a *App) RescanAwards() error {
|
func (a *App) RescanAwards() error {
|
||||||
a.invalidateAwardStats()
|
a.invalidateAwardStats()
|
||||||
|
// Also refresh the materialised award_refs on every QSO (the grid columns read
|
||||||
|
// from there). Manual trigger for when a definition/reference change should be
|
||||||
|
// re-applied to existing rows on demand rather than waiting for the next event.
|
||||||
|
a.recomputeAwardRefsAsync()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3821,7 +3833,12 @@ func (a *App) recomputeAwardRefsAsync() {
|
|||||||
|
|
||||||
// keyAwardsMaterialized marks (per profile / logbook) that the one-time award_refs
|
// keyAwardsMaterialized marks (per profile / logbook) that the one-time award_refs
|
||||||
// backfill has run, so it doesn't re-scan the whole logbook on every launch.
|
// backfill has run, so it doesn't re-scan the whole logbook on every launch.
|
||||||
const keyAwardsMaterialized = "awards.materialized.v1"
|
// keyAwardsMaterialized is versioned: bump the suffix to force every operator to
|
||||||
|
// re-materialise award_refs once on next launch. Needed when the stored values
|
||||||
|
// could be stale against the CURRENT award definitions — e.g. rows materialised
|
||||||
|
// before an award gained a new matching rule (DDFM's postal-code OR-rule), which
|
||||||
|
// the one-shot backfill would otherwise never revisit.
|
||||||
|
const keyAwardsMaterialized = "awards.materialized.v2"
|
||||||
|
|
||||||
// backfillAwardRefsOnce populates award_refs for QSOs that predate the feature
|
// backfillAwardRefsOnce populates award_refs for QSOs that predate the feature
|
||||||
// (or were logged by an older client that didn't materialise them). It runs at
|
// (or were logged by an older client that didn't materialise them). It runs at
|
||||||
@@ -4186,6 +4203,65 @@ func (a *App) ExportAward(code string) (string, error) {
|
|||||||
return a.exportAwardBundle([]string{code}, "OpsLog_award_"+code+".json", "Export award "+code)
|
return a.exportAwardBundle([]string{code}, "OpsLog_award_"+code+".json", "Export award "+code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExportAwardForCatalog writes ONE award as a ready-to-ship CATALOG file — the
|
||||||
|
// exact shape internal/award/catalog/*.json use ({"def":{…},"references":[…]}).
|
||||||
|
//
|
||||||
|
// The workflow it enables: edit an award in the UI, call this with the NEXT
|
||||||
|
// version number, and paste the file over that award's catalog JSON. A new OpsLog
|
||||||
|
// release then carries the change to the whole team: every operator whose copy is
|
||||||
|
// unedited auto-upgrades to it (mergeCatalog), and those who edited it keep theirs
|
||||||
|
// but are offered the update.
|
||||||
|
//
|
||||||
|
// Two things a plain export/mirror can't do and this does, both essential for a
|
||||||
|
// catalog file: it STAMPS the award's Version (the UI save deliberately never
|
||||||
|
// bumps it) and it CLEARS user_edited, so a fresh install seeded from this file is
|
||||||
|
// NOT pre-flagged as the operator's own work — which would otherwise freeze it out
|
||||||
|
// of every future catalog update.
|
||||||
|
func (a *App) ExportAwardForCatalog(code string, version int) (string, error) {
|
||||||
|
if a.awardRefs == nil || a.ctx == nil {
|
||||||
|
return "", fmt.Errorf("db not initialized")
|
||||||
|
}
|
||||||
|
code = strings.ToUpper(strings.TrimSpace(code))
|
||||||
|
var def award.Def
|
||||||
|
found := false
|
||||||
|
for _, d := range a.awardDefs() {
|
||||||
|
if strings.EqualFold(strings.TrimSpace(d.Code), code) {
|
||||||
|
def, found = d, true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return "", fmt.Errorf("unknown award %q", code)
|
||||||
|
}
|
||||||
|
def.Version = version
|
||||||
|
def.UserEdited = false // a catalog seed is not "the operator's edit"
|
||||||
|
def.Builtin = true
|
||||||
|
refs, err := a.awardRefs.List(a.ctx, code)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("load references: %w", err)
|
||||||
|
}
|
||||||
|
entry := struct {
|
||||||
|
Def award.Def `json:"def"`
|
||||||
|
References []awardref.Ref `json:"references,omitempty"`
|
||||||
|
}{Def: def, References: refs}
|
||||||
|
b, err := json.MarshalIndent(entry, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
path, err := wruntime.SaveFileDialog(a.ctx, wruntime.SaveDialogOptions{
|
||||||
|
DefaultFilename: strings.ToLower(code) + ".json",
|
||||||
|
Title: "Export " + code + " for the catalog",
|
||||||
|
Filters: []wruntime.FileFilter{{DisplayName: "JSON (*.json)", Pattern: "*.json"}},
|
||||||
|
})
|
||||||
|
if err != nil || strings.TrimSpace(path) == "" {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(path, b, 0o644); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
|
|
||||||
// exportAwardBundle writes the given award codes (nil = all) to a JSON bundle.
|
// exportAwardBundle writes the given award codes (nil = all) to a JSON bundle.
|
||||||
func (a *App) exportAwardBundle(codes []string, defaultName, title string) (string, error) {
|
func (a *App) exportAwardBundle(codes []string, defaultName, title string) (string, error) {
|
||||||
if a.awardRefs == nil {
|
if a.awardRefs == nil {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
ListCountries, DXCCForCountry, DXCCName,
|
ListCountries, DXCCForCountry, DXCCName,
|
||||||
PopulateBuiltinReferences, HasBuiltinReferences,
|
PopulateBuiltinReferences, HasBuiltinReferences,
|
||||||
ExportAwards, ImportAwards, InspectAwardImport, ApplyAwardImport, GetCatalogCodes, OpenAwardsFolder,
|
ExportAwards, ImportAwards, InspectAwardImport, ApplyAwardImport, GetCatalogCodes, OpenAwardsFolder,
|
||||||
|
ExportAwardForCatalog,
|
||||||
GetAwardUpdates, ApplyAwardUpdate, DismissAwardUpdate, ExplainAward,
|
GetAwardUpdates, ApplyAwardUpdate, DismissAwardUpdate, ExplainAward,
|
||||||
} from '../../wailsjs/go/main/App';
|
} from '../../wailsjs/go/main/App';
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ export type AwardDef = {
|
|||||||
or_rules?: AwardOrRule[];
|
or_rules?: AwardOrRule[];
|
||||||
dxcc_filter: number[] | null; valid_bands?: string[]; valid_modes?: string[]; emission?: string[];
|
dxcc_filter: number[] | null; valid_bands?: string[]; valid_modes?: string[]; emission?: string[];
|
||||||
confirm: string[] | null; validate?: string[] | null; grant_codes?: string; export_credit_granted?: boolean;
|
confirm: string[] | null; validate?: string[] | null; grant_codes?: string; export_credit_granted?: boolean;
|
||||||
total: number; builtin?: boolean;
|
total: number; builtin?: boolean; version?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type AwardOrRule = {
|
type AwardOrRule = {
|
||||||
@@ -155,6 +156,9 @@ export function AwardEditor({ open, onClose, onSaved }: Props) {
|
|||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const [updating, setUpdating] = useState<string | null>(null);
|
const [updating, setUpdating] = useState<string | null>(null);
|
||||||
const [err, setErr] = useState('');
|
const [err, setErr] = useState('');
|
||||||
|
// Version to stamp into a "publish for catalog" export — defaults to one past
|
||||||
|
// the selected award's current version whenever the selection changes.
|
||||||
|
const [catVer, setCatVer] = useState('1');
|
||||||
|
|
||||||
// The err banner doubles as a success/notice area (export path, import counts,
|
// The err banner doubles as a success/notice area (export path, import counts,
|
||||||
// "populated N refs"). Auto-dismiss it after a few seconds so it doesn't stay
|
// "populated N refs"). Auto-dismiss it after a few seconds so it doesn't stay
|
||||||
@@ -212,6 +216,7 @@ export function AwardEditor({ open, onClose, onSaved }: Props) {
|
|||||||
|
|
||||||
const cur = defs[sel];
|
const cur = defs[sel];
|
||||||
const selUpdate = updates.find((u) => (u.code ?? '').toUpperCase() === (cur?.code ?? '').toUpperCase()) ?? null;
|
const selUpdate = updates.find((u) => (u.code ?? '').toUpperCase() === (cur?.code ?? '').toUpperCase()) ?? null;
|
||||||
|
useEffect(() => { setCatVer(String((cur?.version ?? 0) + 1)); }, [cur?.code]);
|
||||||
|
|
||||||
// ── Award tester: run the award's rules against a real QSO and show every step.
|
// ── Award tester: run the award's rules against a real QSO and show every step.
|
||||||
type Rejected = { candidate: string; reason: string };
|
type Rejected = { candidate: string; reason: string };
|
||||||
@@ -299,6 +304,19 @@ export function AwardEditor({ open, onClose, onSaved }: Props) {
|
|||||||
if (p) setErr(t('awed.exportedTo', { path: p }));
|
if (p) setErr(t('awed.exportedTo', { path: p }));
|
||||||
} catch (e: any) { setErr(String(e?.message ?? e)); }
|
} catch (e: any) { setErr(String(e?.message ?? e)); }
|
||||||
}
|
}
|
||||||
|
// Export the SELECTED award as a catalog-ready JSON, stamped with a version, to
|
||||||
|
// paste over internal/award/catalog/<code>.json. A new release then ships it to
|
||||||
|
// the whole team (unedited copies auto-upgrade; edited ones are offered it).
|
||||||
|
async function exportForCatalog() {
|
||||||
|
setErr('');
|
||||||
|
if (!cur) return;
|
||||||
|
const v = Math.trunc(Number(catVer));
|
||||||
|
if (!Number.isFinite(v) || v < 1) { setErr(t('awed.catalogBadVersion')); return; }
|
||||||
|
try {
|
||||||
|
const p = await ExportAwardForCatalog(cur.code.trim().toUpperCase(), v);
|
||||||
|
if (p) setErr(t('awed.catalogExportedTo', { path: p }));
|
||||||
|
} catch (e: any) { setErr(String(e?.message ?? e)); }
|
||||||
|
}
|
||||||
// Import: LOOK FIRST, then ask.
|
// Import: LOOK FIRST, then ask.
|
||||||
//
|
//
|
||||||
// This used to merge by code with "imported wins", silently — import a WAPC
|
// This used to merge by code with "imported wins", silently — import a WAPC
|
||||||
@@ -726,6 +744,18 @@ export function AwardEditor({ open, onClose, onSaved }: Props) {
|
|||||||
title={t('awed.awardsFolderTip')}>
|
title={t('awed.awardsFolderTip')}>
|
||||||
<FolderOpen className="size-3.5 mr-1" /> {t('awed.awardsFolder')}
|
<FolderOpen className="size-3.5 mr-1" /> {t('awed.awardsFolder')}
|
||||||
</Button>
|
</Button>
|
||||||
|
{/* Publish the selected award to the catalog: stamp a version and write a
|
||||||
|
file to paste over internal/award/catalog/<code>.json, so a release
|
||||||
|
ships your change to the whole team. */}
|
||||||
|
{cur && (
|
||||||
|
<div className="flex items-center gap-1" title={t('awed.catalogPublishTip')}>
|
||||||
|
<input type="number" min={1} value={catVer} onChange={(e) => setCatVer(e.target.value)}
|
||||||
|
className="h-8 w-14 rounded border border-input bg-background px-1.5 text-xs font-mono" />
|
||||||
|
<Button variant="outline" onClick={exportForCatalog}>
|
||||||
|
<Download className="size-3.5 mr-1" /> {t('awed.catalogPublish')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
<Button variant="outline" onClick={onClose}>{t('awed.cancel')}</Button>
|
<Button variant="outline" onClick={onClose}>{t('awed.cancel')}</Button>
|
||||||
<Button onClick={save}><Save className="size-3.5 mr-1" /> {t('awed.save')}</Button>
|
<Button onClick={save}><Save className="size-3.5 mr-1" /> {t('awed.save')}</Button>
|
||||||
|
|||||||
@@ -307,6 +307,10 @@ const en: Dict = {
|
|||||||
'awed.builtin': 'Built-in',
|
'awed.builtin': 'Built-in',
|
||||||
'awed.awardsFolder': 'Awards folder',
|
'awed.awardsFolder': 'Awards folder',
|
||||||
'awed.awardsFolderTip': 'Every award you create is saved here as JSON, automatically. To share one, send the file. To receive one, use Import.',
|
'awed.awardsFolderTip': 'Every award you create is saved here as JSON, automatically. To share one, send the file. To receive one, use Import.',
|
||||||
|
'awed.catalogPublish': 'Publish to catalog…',
|
||||||
|
'awed.catalogPublishTip': 'Export this award as a catalog file (with the version on the left), to paste over internal/award/catalog/<code>.json. A new release then ships it to the whole team — copies nobody edited auto-upgrade, edited ones are offered it.',
|
||||||
|
'awed.catalogExportedTo': 'Catalog file written to:\n{path}\n\nPaste it over internal/award/catalog/<code>.json, then build and release.',
|
||||||
|
'awed.catalogBadVersion': 'Enter a version number (1 or more).',
|
||||||
'awed.builtinTip': 'Tick before shipping this award in the catalog. Left off, a “Reset to defaults” DELETES it on the user machine — even though you shipped it.',
|
'awed.builtinTip': 'Tick before shipping this award in the catalog. Left off, a “Reset to defaults” DELETES it on the user machine — even though you shipped it.',
|
||||||
'awed.protectedFlag': 'Protected',
|
'awed.protectedFlag': 'Protected',
|
||||||
'awed.protectedTip': 'Protected awards cannot be deleted from the editor.',
|
'awed.protectedTip': 'Protected awards cannot be deleted from the editor.',
|
||||||
@@ -598,6 +602,10 @@ const fr: Dict = {
|
|||||||
'awed.builtin': 'Intégré',
|
'awed.builtin': 'Intégré',
|
||||||
'awed.awardsFolder': 'Dossier awards',
|
'awed.awardsFolder': 'Dossier awards',
|
||||||
'awed.awardsFolderTip': 'Chaque diplôme que tu crées est enregistré ici en JSON, automatiquement. Pour en partager un : envoie le fichier. Pour en recevoir un : Importer.',
|
'awed.awardsFolderTip': 'Chaque diplôme que tu crées est enregistré ici en JSON, automatiquement. Pour en partager un : envoie le fichier. Pour en recevoir un : Importer.',
|
||||||
|
'awed.catalogPublish': 'Publier au catalogue…',
|
||||||
|
'awed.catalogPublishTip': "Exporte ce diplôme en fichier catalogue (avec la version à gauche), à coller par-dessus internal/award/catalog/<code>.json. Une nouvelle release le diffuse à toute l'équipe — les copies non modifiées s'upgradent seules, les modifiées se le voient proposer.",
|
||||||
|
'awed.catalogExportedTo': 'Fichier catalogue écrit dans :\n{path}\n\nColle-le par-dessus internal/award/catalog/<code>.json, puis build et release.',
|
||||||
|
'awed.catalogBadVersion': 'Entre un numéro de version (1 ou plus).',
|
||||||
'awed.builtinTip': 'À cocher avant de livrer ce diplôme dans le catalogue. Sans ça, un « Réinitialiser par défaut » le SUPPRIME chez l’utilisateur — alors que tu l’as livré.',
|
'awed.builtinTip': 'À cocher avant de livrer ce diplôme dans le catalogue. Sans ça, un « Réinitialiser par défaut » le SUPPRIME chez l’utilisateur — alors que tu l’as livré.',
|
||||||
'awed.protectedFlag': 'Protégé',
|
'awed.protectedFlag': 'Protégé',
|
||||||
'awed.protectedTip': 'Un diplôme protégé ne peut pas être supprimé depuis l’éditeur.',
|
'awed.protectedTip': 'Un diplôme protégé ne peut pas être supprimé depuis l’éditeur.',
|
||||||
|
|||||||
Vendored
+2
@@ -168,6 +168,8 @@ export function ExportADIFSelected(arg1:string,arg2:boolean,arg3:Array<number>):
|
|||||||
|
|
||||||
export function ExportAward(arg1:string):Promise<string>;
|
export function ExportAward(arg1:string):Promise<string>;
|
||||||
|
|
||||||
|
export function ExportAwardForCatalog(arg1:string,arg2:number):Promise<string>;
|
||||||
|
|
||||||
export function ExportAwards():Promise<string>;
|
export function ExportAwards():Promise<string>;
|
||||||
|
|
||||||
export function ExportCabrillo(arg1:string):Promise<main.CabrilloResult>;
|
export function ExportCabrillo(arg1:string):Promise<main.CabrilloResult>;
|
||||||
|
|||||||
@@ -294,6 +294,10 @@ export function ExportAward(arg1) {
|
|||||||
return window['go']['main']['App']['ExportAward'](arg1);
|
return window['go']['main']['App']['ExportAward'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ExportAwardForCatalog(arg1, arg2) {
|
||||||
|
return window['go']['main']['App']['ExportAwardForCatalog'](arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
export function ExportAwards() {
|
export function ExportAwards() {
|
||||||
return window['go']['main']['App']['ExportAwards']();
|
return window['go']['main']['App']['ExportAwards']();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,17 @@
|
|||||||
"type": "QSOFIELDS",
|
"type": "QSOFIELDS",
|
||||||
"field": "note",
|
"field": "note",
|
||||||
"pattern": "(?i)\\b(D\\d{1,2}[AB]?)\\b",
|
"pattern": "(?i)\\b(D\\d{1,2}[AB]?)\\b",
|
||||||
|
"or_rules": [
|
||||||
|
{
|
||||||
|
"field": "address",
|
||||||
|
"match_by": "code",
|
||||||
|
"pattern": "\\b(\\d{2})\\d{3}\\b",
|
||||||
|
"prefix": "D"
|
||||||
|
}
|
||||||
|
],
|
||||||
"dxcc_filter": [
|
"dxcc_filter": [
|
||||||
227
|
227,
|
||||||
|
214
|
||||||
],
|
],
|
||||||
"confirm": [
|
"confirm": [
|
||||||
"lotw",
|
"lotw",
|
||||||
@@ -17,7 +26,9 @@
|
|||||||
"validate": [
|
"validate": [
|
||||||
"lotw"
|
"lotw"
|
||||||
],
|
],
|
||||||
|
"ref_display": "name",
|
||||||
"total": 96,
|
"total": 96,
|
||||||
"builtin": true
|
"builtin": true,
|
||||||
|
"version": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user