mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 21:50:37 -05:00
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:
1 parent
cba0057c9c
commit
9a07c16731
13 files changed
+304
-5
No files matched your search
@@ -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;
|
||||
});
|
||||
};
|
||||
})();
|
||||
@@ -404,6 +404,56 @@ table.cal td.today {
|
||||
outline-offset: -2px !important;
|
||||
}
|
||||
|
||||
/* No-new-work weeks: the checkbox under the week number, and a red ring round the whole week.
|
||||
The ring is drawn by an overlay on each cell of the row, stretched over the 1px cell borders so it
|
||||
joins up, and it lets clicks through to the cell. */
|
||||
.cal .week-number .no-work-week-toggle {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
margin-top: 10px;
|
||||
font-size: 0.7em;
|
||||
font-weight: 600;
|
||||
line-height: 1.1;
|
||||
color: #777;
|
||||
max-width: 4.5em;
|
||||
white-space: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cal .week-number .no-work-week-toggle input { margin: 0; cursor: pointer; }
|
||||
.cal .week-number .no-work-week-toggle input:disabled { cursor: default; }
|
||||
.cal .week-number.no-work-week .no-work-week-toggle { color: #d52b1e; }
|
||||
|
||||
ul.cal li.no-work-week { position: relative; }
|
||||
|
||||
ul.cal li.no-work-week::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -1px;
|
||||
bottom: 0;
|
||||
left: -1px;
|
||||
right: 0;
|
||||
border-top: 3px solid #d52b1e;
|
||||
border-bottom: 3px solid #d52b1e;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
ul.cal li.week-number.no-work-week::after {
|
||||
left: 0;
|
||||
border-left: 3px solid #d52b1e;
|
||||
border-radius: 14px 0 0 14px;
|
||||
}
|
||||
|
||||
ul.cal li.no-work-week.no-work-week-last::after {
|
||||
border-right: 3px solid #d52b1e;
|
||||
border-radius: 0 14px 14px 0;
|
||||
}
|
||||
|
||||
.no-work-week-override label { font-weight: bold; color: #9c1f16; }
|
||||
|
||||
/* Responsive Mobile View */
|
||||
@media screen and (max-width: 768px) {
|
||||
table.cal thead {
|
||||
@@ -444,6 +494,15 @@ table.cal td.today {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Cells are stacked, so ring each one in a flagged week */
|
||||
ul.cal li.no-work-week::after,
|
||||
ul.cal li.week-number.no-work-week::after,
|
||||
ul.cal li.no-work-week.no-work-week-last::after {
|
||||
inset: 0;
|
||||
border: 3px solid #d52b1e;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.appointment-block {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
|
||||
Reference in new issue
Block a user