Calendar review fixes; working day hours setting

- Issues' estimated hours are spread over their working days from start to due date, instead of
  counted in full on both the start and due dates
- Tooltips in the two rightmost columns open leftward again (the rule targeted the old table layout)
- Today scrolls when today is on the page (the check read calendar values that don't exist)
- "Day N of M" on calendar cards and My Page skips holidays; My Page uses the user's date
- Each appointment's working days are worked out once per page (CustomerAppointment#working_days),
  and shared by placement, hours, day numbers and the end date
- The calendar toggles are kept in the session, so changing month loads the page once
- Clicking inside an open tooltip keeps it open; estimates load with the appointments
- Hours in a working day is a plugin setting (default 8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-02 21:12:31 -05:00
1 parent ae522baf63
commit 3a5d83aa69
12 files changed
+148 -187

No files matched your search

+13 -41
View File
@@ -6,6 +6,9 @@ document.addEventListener('DOMContentLoaded', function() {
// Allow standard links (like subject title or avatar links) to navigate normally
if (clickedLink) return;
// Clicks inside an open tooltip (e.g. selecting a phone number to copy) leave it open
if (e.target.closest('.appointment-block .tip')) return;
// Close any other open tooltips across the calendar
document.querySelectorAll('.appointment-block.open').forEach(function(block) {
if (block !== clickedBlock) {
@@ -22,9 +25,6 @@ document.addEventListener('DOMContentLoaded', function() {
});
(function() {
const STORAGE_KEY_ONLY_APPTS = 'redmine_cal_only_appointments';
const STORAGE_KEY_HIDE_PAST = 'redmine_cal_hide_past_weeks';
window.scrollToToday = function() {
const todayElement = document.getElementById('today');
if (todayElement) {
@@ -33,53 +33,25 @@ document.addEventListener('DOMContentLoaded', function() {
};
document.addEventListener('DOMContentLoaded', function() {
const urlParams = new URLSearchParams(window.location.search);
let needsRedirect = false;
// Sync "Show Customer Appointments Only" with localStorage if missing from URL
if (!urlParams.has('only_appointments') && localStorage.getItem(STORAGE_KEY_ONLY_APPTS) === '1') {
urlParams.set('only_appointments', '1');
needsRedirect = true;
}
// Sync "Hide Past Weeks" with localStorage if missing from URL
if (!urlParams.has('hide_past_weeks') && localStorage.getItem(STORAGE_KEY_HIDE_PAST) === '1') {
urlParams.set('hide_past_weeks', '1');
needsRedirect = true;
}
if (needsRedirect) {
window.location.search = urlParams.toString();
return;
}
// Automatically scroll to today if present and no hash anchor is in the URL
if (!window.location.hash) {
window.scrollToToday();
}
});
window.toggleOnlyAppointments = function(checked) {
// The toggles are kept in the session (CalendarsControllerPatch), so turning one off sends 0 rather
// than leaving it out
function setToggle(name, checked) {
const urlParams = new URLSearchParams(window.location.search);
if (checked) {
urlParams.set('only_appointments', '1');
localStorage.setItem(STORAGE_KEY_ONLY_APPTS, '1');
} else {
urlParams.delete('only_appointments');
localStorage.setItem(STORAGE_KEY_ONLY_APPTS, '0');
}
urlParams.set(name, checked ? '1' : '0');
window.location.search = urlParams.toString();
}
window.toggleOnlyAppointments = function(checked) {
setToggle('only_appointments', checked);
};
window.toggleHidePastWeeks = function(checked) {
const urlParams = new URLSearchParams(window.location.search);
if (checked) {
urlParams.set('hide_past_weeks', '1');
localStorage.setItem(STORAGE_KEY_HIDE_PAST, '1');
} else {
urlParams.delete('hide_past_weeks');
localStorage.setItem(STORAGE_KEY_HIDE_PAST, '0');
}
window.location.search = urlParams.toString();
setToggle('hide_past_weeks', checked);
};
})();
})();
+6 -3
View File
@@ -151,8 +151,10 @@ table.cal td {
cursor: default;
}
/* Align tooltips to the right on Friday/Saturday columns */
table.cal td:nth-child(n+6) .appointment-block .tip {
/* Tooltips in the two rightmost day columns open leftward, so they stay on screen. Each calendar row is
8 items (week number, then 7 days), so the last two days are items 8n+7 and 8n. */
ul.cal li.calbody:nth-child(8n+7) .appointment-block .tip,
ul.cal li.calbody:nth-child(8n) .appointment-block .tip {
left: auto !important;
right: 0 !important;
}
@@ -460,7 +462,8 @@ table.cal td.today {
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
}
table.cal td:nth-child(n+6) .appointment-block .tip {
ul.cal li.calbody:nth-child(8n+7) .appointment-block .tip,
ul.cal li.calbody:nth-child(8n) .appointment-block .tip {
left: 50% !important;
right: auto !important;
}