v3.12.0: the card preset carries the card's CAT (USAT) release

The release selector lives in the preset rather than a global chip: presets
already travel with the card (ICCID auto-selection, export/import), and the
operations that will consume the release are preset-aware.

- presets.py: the optional `release` field (4-18; empty = unspecified) joins
  PRESET_FIELDS; a value outside 4-18 is refused on save/import; the store
  schema version is 5.
- catrelease.py: DEFAULT_RELEASE = 12 and preset_release() - the effective
  release is the preset's own value, else Rel-12 (the safe level for cards
  whose release is not known; an unset release never filters anything away).
  The PWA mirrors both (CAT_RELEASE_DEFAULT + presetRelease()), drift-guarded.
- Cards tab: the editor's header row gains a compact CAT release select
  (unspecified / pre-Rel-6 stored as 5 / Rel-6 ... Rel-18); the empty option
  names the Rel-12 default and the tooltip explains the guard; the field is
  collected, cleared and restored with the other form fields.
- Nothing filters yet: the Simulator's event parameters (stage 3) will use
  the effective release.
- docs/api.md + help EN/RU updated; sw cache simple-v368.
This commit is contained in:
2026-10-02 11:28:33 +03:00
parent 2bb1528ca9
commit 3660a7e173
13 changed files with 149 additions and 13 deletions
+16 -1
View File
@@ -58,7 +58,7 @@ code = extractConst(html, 'CARDS_TAR_DEFAULTS') + extractConst(html, 'CARDS_TAR_
eval(code);
globalThis.t = s => s;
const CARD_IDS = ['cards-name','cards-iccid','cards-pin1','cards-puk1','cards-pin2','cards-puk2','cards-adm',
const CARD_IDS = ['cards-name','cards-iccid','cards-release','cards-pin1','cards-puk1','cards-pin2','cards-puk2','cards-adm',
'cards-tars','cards-list-view','cards-editor-view','cards-editor-title','cards-new-btn',
'cards-psk-id','cards-psk-key','cards-keysets',
'cards-add-btn','cards-cancel-btn',
@@ -319,6 +319,21 @@ test('the form values carry the codes and the TAR table', () => {
assert.strictEqual(v.adm, '00112233');
});
test('the release field is collected, cleared and restored', () => {
const els = setup();
els['cards-release'].value = '14';
assert.strictEqual(cardsFormValues().release, '14');
cardsClearForm();
assert.strictEqual(els['cards-release'].value, '');
globalThis.cards = [presetFixture({ name: 'Rel', release: '17' })];
cardsEdit(0);
assert.strictEqual(els['cards-release'].value, '17');
// a preset without a release reads as unspecified
globalThis.cards = [presetFixture({ name: 'Plain' })];
cardsEdit(0);
assert.strictEqual(els['cards-release'].value, '');
});
test('saving a preset posts the form with the pre-settled TAR table', async () => {
const els = setup();
els['cards-name'].value = 'New card';
+14
View File
@@ -32,6 +32,8 @@ function extractFunc(src, name) {
eval(extractBlock('const CAT_RELEASE = {', '// The display label of an introduction release')
.replace(/^const /gm, 'var '));
eval(extractFunc(html, 'catReleaseLabel'));
eval(extractBlock('const CAT_RELEASE_DEFAULT', 'function presetRelease').replace(/^const /gm, 'var '));
eval(extractFunc(html, 'presetRelease'));
eval(extractBlock('const EVENT_NAMES = {', 'const REJECTION_CAUSES = [').replace(/^const /gm, 'var '));
test('CAT_RELEASE carries the introduction releases of the event list', () => {
@@ -77,3 +79,15 @@ test('catReleaseLabel collapses everything below Rel-6', () => {
assert.strictEqual(catReleaseLabel(6), 'Rel-6');
assert.strictEqual(catReleaseLabel(18), 'Rel-18');
});
test('presetRelease resolves unspecified presets to the default', () => {
assert.strictEqual(CAT_RELEASE_DEFAULT, 12);
assert.strictEqual(presetRelease({ release: '14' }), 14);
assert.strictEqual(presetRelease({ release: 4 }), 4);
assert.strictEqual(presetRelease({ release: '18' }), 18);
// an unset or invalid release must never filter anything away
for (const p of [{}, { release: '' }, { release: '0' }, { release: '3' },
{ release: '99' }, { release: 'x' }, null, undefined]) {
assert.strictEqual(presetRelease(p), CAT_RELEASE_DEFAULT, JSON.stringify(p));
}
});