mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-11-17 13:50:36 -05:00
- 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>
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
document.addEventListener('DOMContentLoaded', function() {
|
|
document.addEventListener('click', function(e) {
|
|
const clickedBlock = e.target.closest('.appointment-block');
|
|
const clickedLink = e.target.closest('a');
|
|
|
|
// 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) {
|
|
block.classList.remove('open');
|
|
}
|
|
});
|
|
|
|
// Toggle the clicked appointment block's tooltip
|
|
if (clickedBlock) {
|
|
e.stopPropagation();
|
|
clickedBlock.classList.toggle('open');
|
|
}
|
|
});
|
|
});
|
|
|
|
(function() {
|
|
window.scrollToToday = function() {
|
|
const todayElement = document.getElementById('today');
|
|
if (todayElement) {
|
|
todayElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
}
|
|
};
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Automatically scroll to today if present and no hash anchor is in the URL
|
|
if (!window.location.hash) {
|
|
window.scrollToToday();
|
|
}
|
|
});
|
|
|
|
// 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);
|
|
urlParams.set(name, checked ? '1' : '0');
|
|
window.location.search = urlParams.toString();
|
|
}
|
|
|
|
window.toggleOnlyAppointments = function(checked) {
|
|
setToggle('only_appointments', checked);
|
|
};
|
|
|
|
window.toggleHidePastWeeks = function(checked) {
|
|
setToggle('hide_past_weeks', checked);
|
|
};
|
|
})();
|