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

+96 -9
View File
@@ -3367,7 +3367,8 @@ button.btn-quiet::before {
gap: 1rem;
}
.coordinator-board .desk-panel {
.coordinator-board .desk-panel,
.contacts-board {
display: flex;
flex-direction: column;
gap: 0.8rem;
@@ -3380,7 +3381,8 @@ button.btn-quiet::before {
box-shadow: 0 8px 24px rgb(34 55 70 / 0.05);
}
.coordinator-board .desk-panel h2 {
.coordinator-board .desk-panel h2,
.contacts-board h2 {
margin: 0;
font-size: 1.35rem;
font-weight: 650;
@@ -3688,7 +3690,8 @@ button.btn-quiet::before {
stroke-linejoin: round;
}
.coordinator-board .desk-panel .empty {
.coordinator-board .desk-panel .empty,
.contacts-board .empty {
margin: 0;
padding: 0.85rem 1rem;
background: #f3f7fb;
@@ -3815,19 +3818,29 @@ button.btn-quiet::before {
max-width: 100%;
}
/* Contact rows: light-blue pills on the white panel, like the shift rows. */
.contact-list {
list-style: none;
margin: 1rem 0 0;
display: grid;
gap: 0.55rem;
margin: 0;
padding: 0;
}
.contact-row {
display: grid;
grid-template-columns: minmax(10rem, 1.2fr) minmax(12rem, 1.6fr) minmax(7rem, 0.8fr) auto;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.35rem 1rem;
align-items: baseline;
padding: 0.75rem 0;
border-top: 1px solid var(--hope-border-2);
min-height: 4.15rem;
padding: 0.7rem 0.95rem;
background: #f3f7fb;
border-radius: 0.95rem;
color: var(--hope-ink);
}
.contact-row:hover {
background: #e8f1f7;
}
.contact-row p {
@@ -3839,6 +3852,80 @@ button.btn-quiet::before {
display: none;
}
.contact-row .pick {
flex: none;
justify-content: center;
min-height: 2.4rem;
padding: 0 0.3rem;
cursor: pointer;
}
.contact-row .pick input {
width: 1.25rem;
height: 1.25rem;
margin: 0;
accent-color: var(--hope-ink);
cursor: pointer;
}
.contact-name {
display: flex;
align-items: center;
flex: 1 1 10rem;
min-width: 8rem;
margin: 0;
font-size: 0.98rem;
line-height: 1.3;
}
.contact-name a {
color: inherit;
font-weight: 650;
text-decoration: none;
}
.contact-name a:hover,
.contact-name a:active {
text-decoration: underline;
text-underline-offset: 0.12em;
}
.contact-email {
flex: 1 1 13rem;
min-width: 0;
margin: 0;
color: #7d8b99;
font-size: var(--hope-text-small);
line-height: 1.3;
}
.contact-phone {
flex: 0 1 auto;
margin: 0;
color: #7d8b99;
font-size: var(--hope-text-small);
line-height: 1.3;
white-space: nowrap;
}
.contact-remove {
flex: none;
margin: 0 0 0 auto;
}
@media (max-width: 42em) {
.contact-name {
flex: 1 1 auto;
min-width: 0;
}
.contact-email,
.contact-phone {
flex: 1 1 100%;
white-space: normal;
}
}
.contact-actions {
display: grid;
grid-template-columns: repeat(3, max-content) minmax(0, 1fr);
+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();
})();