release: 3.40.2 — file-filter reset (✕) button
A red ✕ next to the filter selector appears whenever the filter is not "All" and resets it to "All" in one click (pysimFsFilterClear). Bump VERSION/pyproject/PWA header to 3.40.2 and the SW cache to simple-v487.
This commit is contained in:
1 parent
1f8fa54c49
commit
fdbff77188
6 files changed
+54
-8
No files matched your search
+14
-2
@@ -1127,6 +1127,7 @@
|
||||
<button type="button" id="pysim-fs-filter-btn" aria-haspopup="true" aria-expanded="false" onclick="pysimFsFilterToggle()" class="px-2 py-0.5 text-xs rounded border border-gray-300 dark:border-slate-600 hover:bg-gray-200 dark:hover:bg-slate-700 text-gray-700 dark:text-slate-300 max-w-xs truncate">All</button>
|
||||
<div id="pysim-fs-filter-menu" role="group" aria-label="Filter" class="hidden absolute left-0 mt-1 z-50 w-64 max-h-64 overflow-y-auto rounded border border-gray-300 dark:border-slate-600 bg-white dark:bg-slate-800 p-2 shadow-lg"></div>
|
||||
</div>
|
||||
<button type="button" id="pysim-fs-filter-clear" onclick="pysimFsFilterClear()" class="hidden px-1 text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300" data-l10n-title="Reset filter" aria-label="Reset filter">✕</button>
|
||||
</div>
|
||||
<button id="pysim-fs-probe-btn" data-needs="card" onclick="pysimFsProbeAll()" class="w-full mb-1 px-2 py-0.5 rounded bg-gray-600 text-white hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed" data-l10n="Probe all files">Probe all files</button>
|
||||
<div id="pysim-fs-probe-status" class="hidden mb-1 text-gray-500 dark:text-slate-400"></div>
|
||||
@@ -1989,7 +1990,7 @@
|
||||
// ===== Version =====
|
||||
// Single source of truth for the PWA version: shown in the header and used
|
||||
// by the server version check in pysimConnect().
|
||||
const SIMPLE_VERSION = '3.40.1';
|
||||
const SIMPLE_VERSION = '3.40.2';
|
||||
document.getElementById('app-version').textContent = 'v' + SIMPLE_VERSION;
|
||||
|
||||
// ===== view history (the browser Back/Forward buttons) =====
|
||||
@@ -16270,6 +16271,7 @@ function pysimFsFilterRender() {
|
||||
const menu = document.getElementById('pysim-fs-filter-menu');
|
||||
const btn = document.getElementById('pysim-fs-filter-btn');
|
||||
if (!menu) return;
|
||||
const active = pysimFsFilter.size > 0 && !pysimFsFilter.has(FS_FILTER_ALL);
|
||||
const services = fsFilterServiceOptions();
|
||||
const item = (id, label) =>
|
||||
'<label class="flex items-center gap-2 px-2 py-0.5 rounded cursor-pointer hover:bg-gray-100 dark:hover:bg-slate-700 text-xs text-gray-700 dark:text-slate-200">' +
|
||||
@@ -16296,7 +16298,6 @@ function pysimFsFilterRender() {
|
||||
if (btn) {
|
||||
btn.textContent = pysimFsFilterSummary();
|
||||
// a non-"All" selection stands out (blue, like the active sort pill)
|
||||
const active = pysimFsFilter.size > 0 && !pysimFsFilter.has(FS_FILTER_ALL);
|
||||
btn.classList.toggle('bg-blue-600', active);
|
||||
btn.classList.toggle('text-white', active);
|
||||
btn.classList.toggle('text-gray-700', !active);
|
||||
@@ -16304,6 +16305,11 @@ function pysimFsFilterRender() {
|
||||
btn.classList.toggle('hover:bg-gray-200', !active);
|
||||
btn.classList.toggle('dark:hover:bg-slate-700', !active);
|
||||
}
|
||||
const clearBtn = document.getElementById('pysim-fs-filter-clear');
|
||||
if (clearBtn) {
|
||||
clearBtn.classList.toggle('hidden', !active);
|
||||
clearBtn.setAttribute('aria-label', t('Reset filter'));
|
||||
}
|
||||
}
|
||||
|
||||
// Expand or collapse the menu (`force` overrides the toggle; the outside
|
||||
@@ -16339,6 +16345,11 @@ function pysimFsFilterSetEntry(entry, on) {
|
||||
pysimFsAutoExpandForFilter();
|
||||
}
|
||||
|
||||
// The ✕ next to the filter selector: back to "All".
|
||||
function pysimFsFilterClear() {
|
||||
pysimFsFilterSetEntry(FS_FILTER_ALL, true);
|
||||
}
|
||||
|
||||
// The cross-reference inverted to service number -> feature name, per file
|
||||
// table. Both maps are declared later in this file, so they are read on the
|
||||
// first call, never while the filter block itself is evaluated.
|
||||
@@ -28100,6 +28111,7 @@ const LANG_RU = {
|
||||
'Sort:': 'Сортировка:',
|
||||
'Name': 'Имя',
|
||||
'Filter:': 'Фильтр:',
|
||||
'Reset filter': 'Сбросить фильтр',
|
||||
'(no filters yet)': '(фильтров пока нет)',
|
||||
'Identifiers': 'Идентификаторы',
|
||||
'PLMN selection': 'Выбор PLMN',
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
const CACHE = 'simple-v486';
|
||||
const CACHE = 'simple-v487';
|
||||
const URLS = [
|
||||
'index.html',
|
||||
'help.html',
|
||||
|
||||
@@ -111,10 +111,11 @@ function fakeMenu() {
|
||||
};
|
||||
}
|
||||
|
||||
const dom = { menu: null, btn: null };
|
||||
const dom = { menu: null, btn: null, clear: null };
|
||||
globalThis.document = {
|
||||
getElementById: id => (id === 'pysim-fs-filter-menu' ? dom.menu
|
||||
: (id === 'pysim-fs-filter-btn' ? dom.btn : null)),
|
||||
: (id === 'pysim-fs-filter-btn' ? dom.btn
|
||||
: (id === 'pysim-fs-filter-clear' ? dom.clear : null))),
|
||||
};
|
||||
|
||||
let code = '';
|
||||
@@ -123,7 +124,7 @@ for (const f of ['fsFilterServiceOptions', 'fsFilterIndexBuild', 'fsFilterIndex'
|
||||
'fsFilterPathsKeyOf', 'pysimFsFilterPathsInvalidate', 'pysimFsFilterMatchingPaths',
|
||||
'pysimFsFilterMatch', 'pysimFsFilterShow', 'pysimFsFilterLabel',
|
||||
'pysimFsFilterSummary', 'pysimFsFilterRender', 'pysimFsFilterToggle',
|
||||
'pysimFsFilterSetEntry', 'pysimFsFilterRestore', 'pysimFsNodePath',
|
||||
'pysimFsFilterSetEntry', 'pysimFsFilterClear', 'pysimFsFilterRestore', 'pysimFsNodePath',
|
||||
'pysimFsExpandAll', 'pysimFsCollapseAll', 'pysimFsAutoExpandForFilter']) {
|
||||
code += extractFunc(html, f) + '\n';
|
||||
}
|
||||
@@ -161,6 +162,31 @@ test('the file tree has a collapsed filter dropdown next to the sort pills', ()
|
||||
assert.ok(!/pysimFsSetFilter\(/.test(html));
|
||||
});
|
||||
|
||||
test('the ✕ next to the selector resets a non-All filter to All', () => {
|
||||
// markup: a hidden red ✕ that clears the filter
|
||||
assert.match(html, /id="pysim-fs-filter-clear"[^>]*onclick="pysimFsFilterClear\(\)"/);
|
||||
assert.match(html, /id="pysim-fs-filter-clear"[^>]*data-l10n-title="Reset filter"/);
|
||||
// the clear handler resets to All
|
||||
const fn = extractFunc(html, 'pysimFsFilterClear');
|
||||
assert.ok(fn.indexOf('pysimFsFilterSetEntry(FS_FILTER_ALL, true)') > 0, fn);
|
||||
// the render shows it only when a non-All filter is active
|
||||
dom.menu = fakeMenu();
|
||||
dom.btn = fakeBtn();
|
||||
dom.clear = fakeBtn();
|
||||
withFilter(['plmn-selection'], () => {
|
||||
pysimFsFilterRender();
|
||||
assert.strictEqual(dom.clear.classes.has('hidden'), false);
|
||||
assert.strictEqual(dom.clear.attrs['aria-label'], 'Reset filter');
|
||||
});
|
||||
withFilter(['all'], () => {
|
||||
pysimFsFilterRender();
|
||||
assert.strictEqual(dom.clear.classes.has('hidden'), true);
|
||||
});
|
||||
// the Russian entry exists
|
||||
const dict = html.match(/const LANG_RU = \{([\s\S]*?)\n\};/)[1];
|
||||
assert.ok(dict.includes("'Reset filter':"), 'missing Russian entry');
|
||||
});
|
||||
|
||||
test('an outside click or Escape closes the menu', () => {
|
||||
const click = html.match(/document\.addEventListener\('click', e => \{([\s\S]{0,600}?)\n\}\);/);
|
||||
assert.ok(click, 'no document click listener');
|
||||
|
||||
Reference in new issue
Block a user