feat: add volunteer shift signup app

Initial source, tests, migrations, and local Docker setup for the Hope Food Pantry volunteer scheduler.
This commit is contained in:
blake committed 2026-10-16 09:33:39 -05:00
commit f1a46e2ba7
129 files changed
+25290

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
(function () {
var dialog = document.getElementById('confirm');
if (!dialog || typeof dialog.showModal !== 'function') return;
var form = document.getElementById('confirm-form');
var title = document.getElementById('confirm-title');
var detail = document.getElementById('confirm-detail');
var body = document.getElementById('confirm-body');
var note = document.getElementById('confirm-note');
var submit = document.getElementById('confirm-submit');
var cancel = document.getElementById('confirm-cancel');
var error = document.getElementById('confirm-error');
if (!form || !title || !detail || !body || !note || !submit || !cancel) return;
var text = function (link, name) {
return link.getAttribute(name) || '';
};
var chosenFor = function (name) {
return document.querySelectorAll('input[data-pick="' + name + '"]:checked');
};
var fill = function (link) {
form.querySelectorAll('[data-picked]').forEach(function (input) {
input.remove();
});
form.action = text(link, 'data-confirm-action') || link.getAttribute('href') || '';
title.textContent = text(link, 'data-confirm-title') || 'Remove';
body.textContent = text(link, 'data-confirm-body');
var when = text(link, 'data-confirm-detail');
detail.textContent = when;
detail.hidden = when === '';
var extra = text(link, 'data-confirm-note');
note.textContent = extra;
note.hidden = extra === '';
var label = text(link, 'data-confirm-submit');
submit.textContent = label || 'Remove';
submit.hidden = label === '';
submit.disabled = label === '';
cancel.textContent = label === '' ? 'Close' : 'Cancel';
if (error) {
error.textContent = '';
error.hidden = true;
}
var pick = link.getAttribute('data-confirm-pick');
if (!pick) return;
var chosen = chosenFor(pick);
var weekly = false;
chosen.forEach(function (box) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = pick + '[]';
input.value = box.value;
input.setAttribute('data-picked', '');
form.appendChild(input);
if (box.getAttribute('data-weekly') === 'true') weekly = true;
});
detail.textContent = chosen.length === 1 ? '1 selected' : chosen.length + ' selected';
detail.hidden = false;
var weeklyNote = text(link, 'data-confirm-note-weekly');
if (weekly && weeklyNote) {
note.textContent = weeklyNote;
note.hidden = false;
}
};
var show = function () {
if (dialog.open) dialog.close();
dialog.showModal();
dialog.classList.add('is-modal');
var focus = submit.hidden ? cancel : submit;
if (focus) focus.focus();
};
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;
});
document.querySelectorAll('[data-pick-all]').forEach(function (all) {
var name = all.getAttribute('data-pick-all');
if (!name) return;
var boxes = document.querySelectorAll('input[data-pick="' + name + '"]');
var checked = chosenFor(name);
all.checked = boxes.length > 0 && checked.length === boxes.length;
all.indeterminate = checked.length > 0 && checked.length < boxes.length;
});
};
document.querySelectorAll('[data-confirm]').forEach(function (link) {
link.addEventListener('click', function (event) {
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
var pick = link.getAttribute('data-confirm-pick');
if (pick && chosenFor(pick).length === 0) {
event.preventDefault();
return;
}
event.preventDefault();
fill(link);
show();
});
});
document.querySelectorAll('[data-pick-all]').forEach(function (all) {
all.addEventListener('change', function () {
var name = all.getAttribute('data-pick-all');
if (!name) return;
var checked = all.checked;
document.querySelectorAll('input[data-pick="' + name + '"]').forEach(function (box) {
box.checked = checked;
});
syncPicks();
});
});
document.querySelectorAll('input[data-pick]').forEach(function (box) {
box.addEventListener('change', syncPicks);
});
dialog.addEventListener('click', function (event) {
if (event.target === dialog) dialog.close();
});
dialog.addEventListener('close', function () {
if (!dialog.open) dialog.classList.remove('is-modal');
});
syncPicks();
if (dialog.open) show();
})();
+65
View File
@@ -0,0 +1,65 @@
(function () {
var key = 'hope-place';
var place = null;
try {
var raw = sessionStorage.getItem(key);
if (raw) {
sessionStorage.removeItem(key);
place = JSON.parse(raw);
}
} catch (err) {
place = null;
}
var restore = place && place.path === location.pathname && typeof place.y === 'number' && place.y > 0;
if (restore && 'scrollRestoration' in history) history.scrollRestoration = 'manual';
var scrollToY = function (y) {
var root = document.documentElement;
var previous = root.style.scrollBehavior;
root.style.scrollBehavior = 'auto';
window.scrollTo(0, y);
root.scrollTop = y;
if (document.body) document.body.scrollTop = y;
root.style.scrollBehavior = previous;
};
if (restore) scrollToY(place.y);
document.addEventListener(
'submit',
function (event) {
var form = event.target;
if (!form || !form.hasAttribute || !form.hasAttribute('data-keep-place')) return;
var y = window.scrollY || document.documentElement.scrollTop || (document.body ? document.body.scrollTop : 0) || 0;
try {
sessionStorage.setItem(key, JSON.stringify({ path: location.pathname, y: y }));
} catch (err) {}
},
true,
);
var bind = function () {
if (restore) scrollToY(place.y);
if (location.search.indexOf('notice=') !== -1) {
try {
var url = new URL(location.href);
if (url.searchParams.has('notice')) {
url.searchParams.delete('notice');
history.replaceState(null, '', url.pathname + url.search + url.hash);
}
} catch (err) {}
}
document.querySelectorAll('[data-dismiss-notice]').forEach(function (button) {
button.addEventListener('click', function () {
var notice = button.closest('[data-notice]');
if (notice) notice.remove();
});
});
};
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', bind);
else bind();
window.addEventListener('load', function () {
if (restore) scrollToY(place.y);
});
})();
+54
View File
@@ -0,0 +1,54 @@
(function () {
bindCalendar();
var boxes = document.querySelectorAll('[data-under-18]');
for (var i = 0; i < boxes.length; i += 1) bind(boxes[i]);
function bindCalendar() {
var calendar = document.querySelector('.shift-calendar');
var weeks = document.querySelectorAll('.cal-week');
if (!calendar || !weeks.length) return;
calendar.classList.add('js');
var wide = window.matchMedia('(min-width: 42.001em) and (max-width: 75em)');
var syncAll = function () {
for (var i = 0; i < weeks.length; i += 1) syncWeek(weeks[i], wide.matches);
};
for (var i = 0; i < weeks.length; i += 1) {
var details = weeks[i].querySelectorAll('details.day-reveal');
for (var j = 0; j < details.length; j += 1) details[j].addEventListener('toggle', syncAll);
}
if (wide.addEventListener) wide.addEventListener('change', syncAll);
syncAll();
}
function syncWeek(week, wide) {
var tray = week.querySelector('.week-tray');
if (!tray) return;
var details = week.querySelectorAll('details.day-reveal');
for (var i = 0; i < details.length; i += 1) {
var detail = details[i];
var date = detail.getAttribute('data-date');
if (!date || !detail.parentNode) continue;
var drawer = week.querySelector('.shift-drawer[data-date="' + date + '"]');
if (!drawer) continue;
if (wide && detail.open) {
if (drawer.parentNode !== tray) tray.appendChild(drawer);
} else if (drawer.parentNode === tray) {
detail.parentNode.appendChild(drawer);
}
}
}
function bind(box) {
var form = box.form;
if (!form) return;
var guardian = form.querySelector('[data-guardian]');
if (!guardian) return;
var inputs = guardian.querySelectorAll('input');
var sync = function () {
var on = box.checked;
for (var j = 0; j < inputs.length; j += 1) inputs[j].required = on;
};
box.addEventListener('change', sync);
sync();
}
})();
+34
View File
@@ -0,0 +1,34 @@
(function () {
var dialog = document.getElementById('new-event');
if (!dialog || typeof dialog.showModal !== 'function') return;
var show = function () {
if (dialog.open) dialog.close();
dialog.showModal();
dialog.classList.add('is-modal');
var field = dialog.querySelector('input[name="title"]');
if (field) field.focus();
};
document.querySelectorAll('[data-open-event]').forEach(function (link) {
link.addEventListener('click', function (event) {
event.preventDefault();
if (dialog.open && dialog.classList.contains('is-modal')) {
var field = dialog.querySelector('input[name="title"]');
if (field) field.focus();
return;
}
show();
});
});
dialog.addEventListener('click', function (event) {
if (event.target === dialog) dialog.close();
});
dialog.addEventListener('close', function () {
if (!dialog.open) dialog.classList.remove('is-modal');
});
if (dialog.open) show();
})();