No-new-work weeks on the calendar

A checkbox under each week number flags the week "no new work" and circles
it in red. New appointments in a flagged week (or ones moved or lengthened
into it) warn on the form and are stopped on save; users with "Override
no-new-work weeks" can tick "Schedule anyway". Flagging needs "Flag
no-new-work weeks". Call-outs aren't affected. Adds migration 005.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-06 10:16:10 -05:00
1 parent cba0057c9c
commit 9a07c16731
13 files changed
+304 -5

No files matched your search

+26
View File
@@ -54,4 +54,30 @@ document.addEventListener('DOMContentLoaded', function() {
window.toggleHidePastWeeks = function(checked) {
setToggle('hide_past_weeks', checked);
};
// The checkbox at the start of each week: flags it "no new work" (circled in red) without reloading
window.toggleNoWorkWeek = function(checkbox, week) {
const calendar = checkbox.closest('ul.cal');
const token = document.querySelector('meta[name="csrf-token"]');
const body = new URLSearchParams({ week: week, flagged: checkbox.checked ? '1' : '0' });
const cells = calendar.querySelectorAll('li[data-no-work-week="' + week + '"]');
checkbox.disabled = true;
fetch(calendar.dataset.noWorkWeeksUrl, {
method: 'POST',
headers: { 'Accept': 'application/json', 'X-CSRF-Token': token ? token.content : '' },
body: body,
credentials: 'same-origin'
}).then(function(response) {
if (!response.ok) throw new Error(response.status);
return response.json();
}).then(function(data) {
cells.forEach(function(cell) { cell.classList.toggle('no-work-week', data.flagged); });
}).catch(function() {
checkbox.checked = !checkbox.checked;
alert(calendar.dataset.noWorkWeekError || 'Could not save the week');
}).finally(function() {
checkbox.disabled = false;
});
};
})();