Bugzilla – Attachment 169581 Details for
Bug 34440
Add warm-up and cool-down periods to bookings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34440: Enforce lead/trail restrictions
Bug-34440-Enforce-leadtrail-restrictions.patch (text/plain), 6.50 KB, created by
Martin Renvoize (ashimema)
on 2024-07-25 15:44:23 UTC
(
hide
)
Description:
Bug 34440: Enforce lead/trail restrictions
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-07-25 15:44:23 UTC
Size:
6.50 KB
patch
obsolete
>From d02e800c0f08a065ed90ed1a19f7e402717855ae Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 25 Jul 2024 16:15:18 +0100 >Subject: [PATCH] Bug 34440: Enforce lead/trail restrictions > >This patch adds rule enforcement into the user interface. When >attempting to make a booking now, instead of just visually displaying >the lead and trail period and highlighting when an overlap appears, we >now block the ability to select a date when such an overlap case is >found. >--- > .../prog/css/src/staff-global.scss | 12 ++++++ > .../prog/js/modals/place_booking.js | 39 +++++++++++++++++-- > 2 files changed, 47 insertions(+), 4 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 adc9470dc22..22d52bc7057 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -871,6 +871,18 @@ $dayTrailBackground: #fcdcb3 !default; > &.trailRangeEnd { > border-radius: 0 50px 50px 0; > } >+ >+ &.leadDisable { >+ color: #aaa !important; /* Gray out the text */ >+ background: #f5f5f5 !important; /* Light background */ >+ cursor: not-allowed !important; >+ } >+ >+ &.trailDisable { >+ color: #aaa !important; /* Gray out the text */ >+ background: #f5f5f5 !important; /* Light background */ >+ 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 bbb19aa899d..f5c92d0c53a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >@@ -389,6 +389,7 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > periodPicker.config.disable.push(function dateDisable( > date > ) { >+ > // set local copy of selectedDates > let selectedDates = periodPicker.selectedDates; > >@@ -785,6 +786,7 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > instance, > dayElem > ) { >+ const date = dayElem.dateObj > const currentDate = dayElem.dateObj > .toISOString() > .split("T")[0]; >@@ -813,8 +815,8 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > ); > const startDate = periodPicker.selectedDates[0] > ? dayjs(periodPicker.selectedDates[0]).startOf( >- "day" >- ) >+ "day" >+ ) > : null; > > const leadStart = startDate >@@ -824,6 +826,8 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > const trailStart = hoverDate; > const trailEnd = hoverDate.add(trailDays, "day"); > >+ let leadDisable = false; >+ let trailDisable = false; > periodPicker.calendarContainer > .querySelectorAll(".flatpickr-day") > .forEach(function (dayElem) { >@@ -838,7 +842,7 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > dayElem.classList.toggle( > "leadRange", > elemDate.isSameOrAfter(leadStart) && >- elemDate.isBefore(leadEnd) >+ elemDate.isBefore(leadEnd) > ); > dayElem.classList.toggle( > "leadRangeEnd", >@@ -851,17 +855,44 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > dayElem.classList.toggle( > "trailRange", > elemDate.isAfter(trailStart) && >- elemDate.isSameOrBefore(trailEnd) >+ elemDate.isSameOrBefore(trailEnd) > ); > dayElem.classList.toggle( > "trailRangeEnd", > elemDate.isSame(trailEnd) > ); >+ // If we're overlapping a disabled date, disable our hoverDate >+ if (dayElem.classList.contains("flatpickr-disabled")) { >+ if (elemDate.isSameOrAfter(leadStart) && elemDate.isBefore(leadEnd)) { >+ leadDisable = true; >+ } >+ if (elemDate.isAfter(trailStart) && >+ elemDate.isSameOrBefore(trailEnd)) { >+ trailDisable = true; >+ } >+ } >+ dayElem.classList.remove("leadDisable"); >+ dayElem.classList.remove("trailDisable"); >+ dayElem.removeEventListener('click', disableClick, true); > }); >+ >+ if (leadDisable) { >+ target.classList.add("leadDisable"); >+ } >+ if (trailDisable) { >+ target.classList.add("trailDisable"); >+ } >+ if (trailDisable || leadDisable) { >+ target.addEventListener('click', disableClick, true); >+ } > } > } > ); > >+ function disableClick(e) { >+ e.stopImmediatePropagation(); >+ } >+ > // Enable flatpickr now we have date function populated > periodPicker.redraw(); > >-- >2.45.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34440
:
167948
|
167949
|
167950
|
167951
|
167952
|
167953
|
167954
|
167955
|
168941
|
168942
|
168943
|
168944
|
168945
|
168946
|
168947
|
168948
|
168949
|
168998
|
168999
|
169000
|
169001
|
169002
|
169003
|
169004
|
169005
|
169006
|
169007
|
169571
|
169572
|
169573
|
169574
|
169575
|
169576
|
169577
|
169578
|
169579
|
169580
|
169581
|
169587
|
169588
|
170032
|
170033
|
170034
|
170035
|
170036
|
170037
|
170038
|
170039
|
170040
|
170041
|
170042
|
170046
|
170047
|
170048
|
170049
|
170050
|
170051
|
170052
|
170053
|
170054
|
170055
|
170056
|
170589
|
170590
|
170591
|
170592
|
170593
|
170594
|
170595
|
170596
|
170597
|
170598
|
170599
|
170600
|
170603
|
170610
|
170951