From e58ffa85ec5255869a88696c31284494d9f6fdac Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 26 Jul 2024 09:13:02 +0100 Subject: [PATCH] Bug 37363: Initial work on supporting closed days This is just a proof of concept at this point.. we need api's for fetching regular and irregular closed days before we can fully impliment the functionality. --- .../prog/css/src/staff-global.scss | 6 ++++++ .../prog/js/modals/place_booking.js | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 22d52bc7057..58ae4f025f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -883,6 +883,12 @@ $dayTrailBackground: #fcdcb3 !default; background: #f5f5f5 !important; /* Light background */ cursor: not-allowed !important; } + + &.closed-day { + color: #aaa !important; + background: #FFFF99 !important; + cursor: not-allowed !important; + } } .input-warning { diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js index a298f441844..4268d3c6969 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -784,15 +784,26 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { instance, dayElem ) { - const currentDate = dayElem.dateObj + const currentDate = dayElem.dateObj; + const dateString = currentDate .toISOString() .split("T")[0]; - if (bookingsByDate[currentDate]) { + // Make closed days unclickable (while keeping them part of the range) + if (currentDate.getDay() === 0 || currentDate.getDay() === 6) { + dayElem.classList.add("closed-day"); + + // Remove the click event to disable the day + dayElem.addEventListener('click', function(event) { + event.stopImmediatePropagation(); + }, true); + } + + if (bookingsByDate[dateString]) { const dots = document.createElement("span"); dots.className = "event-dots"; dayElem.appendChild(dots); - bookingsByDate[currentDate].forEach(item => { + bookingsByDate[dateString].forEach(item => { const dot = document.createElement("span"); dot.className = "event item_" + item; dots.appendChild(dot); -- 2.45.2