Bugzilla – Attachment 169591 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), 5.32 KB, created by
Martin Renvoize (ashimema)
on 2024-07-25 16:12:17 UTC
(
hide
)
Description:
Bug 37354: Add visual hint at usual loan periods
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-07-25 16:12:17 UTC
Size:
5.32 KB
patch
obsolete
>From 3840b433425150c4adcceefa970504d7b19a492d 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. >--- > .../prog/js/modals/place_booking.js | 46 +++++++++++++++---- > 1 file changed, 38 insertions(+), 8 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 30e647c9d8a..e3315616792 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", >@@ -146,8 +150,9 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > }, > 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; > >@@ -676,9 +681,28 @@ $("#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); >@@ -795,15 +819,21 @@ $("#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.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 37354
:
168950
|
168964
|
168965
|
168966
|
168967
|
169008
|
169009
|
169590
|
169591
|
169685
|
169686
|
170066
|
170067
|
172890
|
172891
|
173137
|
173210
|
173620
|
173621
|
173622
|
173623