feat(awards): wire up the single-award export
Only the whole-catalogue bundle was reachable from the UI, so sharing one award meant handing over every award you have — including the ones you edited for yourself. Nothing new was needed underneath: ExportAward(code) already existed and already reads the definition AND its references from the database rather than from the embedded catalog, which is the point (a WAPC is only worth sharing because of the province list and city regexes the operator added). The English and French strings existed too. Only the button was missing. Kept distinct from the catalog publish next to it: that one stamps a version and clears user_edited to seed a release, this one is a plain share and leaves both alone, so the recipient's copy is correctly marked as someone else's work instead of a pristine built-in that future catalog updates would overwrite.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Plus, Trash2, RotateCcw, Save, Download, Upload, Loader2, Search, FolderOpen, ArrowUpCircle } from 'lucide-react';
|
||||
import { Plus, Trash2, RotateCcw, Save, Download, Upload, Loader2, Search, FolderOpen, ArrowUpCircle, Share2 } from 'lucide-react';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
ListCountries, DXCCForCountry, DXCCName,
|
||||
PopulateBuiltinReferences, HasBuiltinReferences,
|
||||
ExportAwards, ImportAwards, InspectAwardImport, ApplyAwardImport, GetCatalogCodes, OpenAwardsFolder,
|
||||
ExportAwardForCatalog,
|
||||
ExportAwardForCatalog, ExportAward,
|
||||
GetAwardUpdates, ApplyAwardUpdate, DismissAwardUpdate, ExplainAward,
|
||||
} from '../../wailsjs/go/main/App';
|
||||
|
||||
@@ -307,6 +307,23 @@ export function AwardEditor({ open, onClose, onSaved }: Props) {
|
||||
if (p) setErr(t('awed.exportedTo', { path: p }));
|
||||
} catch (e: any) { setErr(String(e?.message ?? e)); }
|
||||
}
|
||||
// Export the SELECTED award on its own — the unit you actually share. The
|
||||
// bundle above is a backup: sending it to someone hands over your whole
|
||||
// catalogue when they asked for one award.
|
||||
//
|
||||
// Distinct from the catalog publish below, which is for shipping an award INTO
|
||||
// OpsLog: that one stamps a version and clears user_edited. This one is a plain
|
||||
// share and leaves both alone, so the recipient's copy is correctly marked as
|
||||
// someone else's work rather than as a pristine built-in.
|
||||
async function exportOne() {
|
||||
setErr('');
|
||||
if (!cur) return;
|
||||
try {
|
||||
const code = cur.code.trim().toUpperCase();
|
||||
const p = await ExportAward(code);
|
||||
if (p) setErr(t('awed.exportedOneTo', { code, path: p }));
|
||||
} 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).
|
||||
@@ -780,6 +797,14 @@ export function AwardEditor({ open, onClose, onSaved }: Props) {
|
||||
<Button variant="outline" onClick={exportAwards} title={t('awed.exportTitle')}>
|
||||
<Download className="size-3.5 mr-1" /> {t('awed.export')}
|
||||
</Button>
|
||||
{/* Share just the selected one. Sitting next to the whole-catalogue
|
||||
export because that is where an operator looks for it, and labelled
|
||||
with the code so the two are never confused at a glance. */}
|
||||
{cur && (
|
||||
<Button variant="outline" onClick={exportOne} title={t('awed.exportOneTitle')}>
|
||||
<Share2 className="size-3.5 mr-1" /> {t('awed.exportOne', { code: cur.code.trim().toUpperCase() })}
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="outline" onClick={importAwards} title={t('awed.importTitle')}>
|
||||
<Upload className="size-3.5 mr-1" /> {t('awed.import')}
|
||||
</Button>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user