Bugzilla – Attachment 174276 Details for
Bug 37354
Bookings should respect circulation rules for max loan periods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37354: Add visual hint at usual loan periods
Bug-37354-Add-visual-hint-at-usual-loan-periods.patch (text/plain), 6.47 KB, created by
Martin Renvoize (ashimema)
on 2024-11-08 15:29:12 UTC
(
hide
)
Description:
Bug 37354: Add visual hint at usual loan periods
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-11-08 15:29:12 UTC
Size:
6.47 KB
patch
obsolete
>From 2bdfe18df5a76274b4def78ff94d447ce97af39d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Sun, 14 Jul 2024 08:57:22 +0100 >Subject: [PATCH] Bug 37354: Add visual hint at usual loan periods > >This patch adds a visual hint to the datepicker to highlight dates that >line up with normal loan and renewal lengths. > >We use bold to highlight such dates. > >Test plan >1) Repeat the test plan for the previous patch >2) Note that once you have selected your first date, that date will > become bold, the date a 'Loan period' after the start date will also > be bold and you'll also have bold dates for the number of 'Renewals > allowed' at each 'Renewal period' beyond the initial 'Loan period' > date. > >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../prog/js/modals/place_booking.js | 62 ++++++++++++++++--- > 1 file changed, 52 insertions(+), 10 deletions(-) > >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 500bfcdf391..728dc76d3f4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >@@ -132,8 +132,12 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > // Lead and Trail days syncing > let leadDays = 0; > let trailDays = 0; >- let lengthDays; >+ let boldDates = []; >+ let issueLength; >+ let renewalLength; >+ let renewalsAllowed; > function getCirculationRules() { >+ let rules_url = "/api/v1/circulation_rules"; > $.ajax({ > url: rules_url, > type: "GET", >@@ -142,12 +146,13 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > patron_category_id: booking_patron.category_id, > item_type_id: booking_itemtype_id, > library_id: pickup_library_id, >- rules: "bookings_lead_period,bookings_trail_period,issuelength,renewalsallowed,renewalperiod" >+ rules: "bookings_lead_period,bookings_trail_period,issuelength,renewalsallowed,renewalperiod", > }, > success: function (response) { > let rules = response[0]; >- let renewalLength = rules.renewalsallowed * rules.renewalperiod; >- lengthDays = rules.issuelength + renewalLength; >+ issueLength = rules.issuelength; >+ renewalsAllowed = rules.renewalsallowed; >+ renewalLength = rules.renewalperiod; > leadDays = rules.bookings_lead_period; > trailDays = rules.bookings_trail_period; > >@@ -680,12 +685,40 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > ) { > // Start date selected > if (selectedDates[0] && !selectedDates[1]) { >+ const startDate = new Date(selectedDates[0]); >+ >+ // Custom format function to make specific dates bold >+ boldDates = [new Date(startDate)]; >+ // Add issueLength days after the startDate >+ const nextDate = new Date(startDate); >+ nextDate.setDate( >+ nextDate.getDate() + parseInt(issueLength) >+ ); >+ boldDates.push(new Date(nextDate)); >+ >+ // Add subsequent dates based on renewalsAllowed and renewalLength >+ for (let i = 0; i < renewalsAllowed; i++) { >+ nextDate.setDate( >+ nextDate.getDate() + parseInt(renewalLength) >+ ); >+ boldDates.push(new Date(nextDate)); >+ } >+ > // Calculate the maximum date based on the selected start date >- const maxDate = new Date(selectedDates[0]); >- maxDate.setDate(maxDate.getDate() + lengthDays ); >+ let totalRenewalLength = >+ parseInt(renewalsAllowed) * >+ parseInt(renewalLength); >+ let totalIssueLength = >+ parseInt(issueLength) + >+ parseInt(totalRenewalLength); >+ >+ const maxDate = new Date(startDate.getTime()); >+ maxDate.setDate( >+ maxDate.getDate() + totalIssueLength >+ ); > > // Update the maxDate option of the flatpickr instance >- instance.set('maxDate', maxDate); >+ instance.set("maxDate", maxDate); > } > // Range set, update hidden fields and set available items > else if (selectedDates[0] && selectedDates[1]) { >@@ -799,15 +832,24 @@ $("#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]) { >+ const isBold = boldDates.some( >+ boldDate => >+ boldDate.getTime() === currentDate.getTime() >+ ); >+ if (isBold) { >+ dayElem.classList.add("title"); >+ } >+ >+ 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.47.0
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 37354
:
168950
|
168964
|
168965
|
168966
|
168967
|
169008
|
169009
|
169590
|
169591
|
169685
|
169686
|
170066
|
170067
|
172890
|
172891
|
173137
|
173210
|
173620
|
173621
|
173622
|
173623
|
174275
| 174276 |
174277
|
174278
|
174279