feat: contacts as pills on a white card; remove several at once

- Contacts list sits in the same white card as the Shifts panels, and each
  contact is a light-blue pill like a shift row. Stacks cleanly on phones.
- Each contact has a checkbox, with Select all and Remove selected. The
  confirm dialog says how many contacts will be removed.
- Select all only ticks contacts currently shown, never rows still behind
  "See more"; revealing more rows leaves Select all partial, not extended.
  This applies to every picker but changes nothing where no rows are hidden.
- POST /admin/contacts/remove: session, origin and CSRF checked; one
  transaction; if any contact is missing, none are removed; one audit row.
  Signups are never touched and no email is sent.
- tests: 5 new contact tests.
This commit is contained in:
Cosmically Creative committed 2026-11-20 13:24:23 -06:00
1 parent bf3724d531
commit b142dd9748
7 files changed
+324 -18

No files matched your search

+26 -4
View File
@@ -15,12 +15,23 @@
return link.getAttribute(name) || '';
};
// A box inside a [hidden] subtree is not shown to the user (rows still behind "See more"), so it never counts.
var visibleBoxes = function (selector) {
var all = document.querySelectorAll(selector);
var shown = [];
for (var i = 0; i < all.length; i += 1) {
if (all[i].closest('[hidden]')) continue;
shown.push(all[i]);
}
return shown;
};
var chosenFor = function (name) {
return document.querySelectorAll('input[data-pick="' + name + '"]:checked');
return visibleBoxes('input[data-pick="' + name + '"]:checked');
};
var boxesFor = function (name) {
return document.querySelectorAll('input[data-pick="' + name + '"]');
return visibleBoxes('input[data-pick="' + name + '"]');
};
var fill = function (link) {
@@ -88,7 +99,12 @@
if (blocked > 0 && kept.length > 0) {
detail.textContent = kept.length + ' of ' + chosen.length + ' can be ' + verb;
} else {
detail.textContent = chosen.length === 1 ? '1 selected' : chosen.length + ' selected';
var unit = text(link, 'data-confirm-unit');
if (unit) {
detail.textContent = chosen.length === 1 ? '1 ' + unit + ' will be removed.' : chosen.length + ' ' + unit + 's will be removed.';
} else {
detail.textContent = chosen.length === 1 ? '1 selected' : chosen.length + ' selected';
}
}
detail.hidden = false;
if (weekly && weeklyNote) notes.push(weeklyNote);
@@ -109,7 +125,8 @@
var syncPicks = function () {
document.querySelectorAll('[data-confirm-pick]').forEach(function (control) {
var name = control.getAttribute('data-confirm-pick');
control.hidden = !name || chosenFor(name).length === 0;
var hide = !name || chosenFor(name).length === 0;
if (control.hidden !== hide) control.hidden = hide;
});
document.querySelectorAll('[data-pick-all]').forEach(function (all) {
var name = all.getAttribute('data-pick-all');
@@ -163,5 +180,10 @@
});
syncPicks();
// Re-check the pick state when rows appear or disappear, e.g. "See more" revealing contacts.
// The guarded writes in syncPicks keep this from looping.
if (typeof MutationObserver === 'function') {
new MutationObserver(syncPicks).observe(document.body, { attributes: true, attributeFilter: ['hidden'], subtree: true });
}
if (dialog.open) show();
})();