Bugzilla – Attachment 170037 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: Simplify modal code using isSameOr* functions
Bug-34440-Simplify-modal-code-using-isSameOr-funct.patch (text/plain), 14.88 KB, created by
Martin Renvoize (ashimema)
on 2024-08-03 06:20:28 UTC
(
hide
)
Description:
Bug 34440: Simplify modal code using isSameOr* functions
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-08-03 06:20:28 UTC
Size:
14.88 KB
patch
obsolete
>From 88a664f9dd348d9d5c7c53e14eea08d0220e242a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 26 Mar 2024 13:38:34 +0000 >Subject: [PATCH] Bug 34440: Simplify modal code using isSameOr* functions > >--- > .../prog/en/modules/bookings/list.tt | 5 +- > .../prog/en/modules/catalogue/ISBDdetail.tt | 5 + > .../prog/en/modules/catalogue/MARCdetail.tt | 5 + > .../prog/en/modules/catalogue/detail.tt | 6 +- > .../prog/en/modules/catalogue/imageviewer.tt | 5 + > .../en/modules/catalogue/labeledMARCdetail.tt | 5 + > .../prog/en/modules/catalogue/moredetail.tt | 4 + > .../prog/js/modals/place_booking.js | 127 ++++++------------ > 8 files changed, 75 insertions(+), 87 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >index 619397a1f63..e43392ed25d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/bookings/list.tt >@@ -63,7 +63,6 @@ > [% INCLUDE modals/cancel_booking.inc %] > > [% MACRO jsinclude BLOCK %] >- [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] > [% Asset.js("lib/vis-timeline/vis-timeline-graph2d.min.js") | $raw %] > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'columns_settings.inc' %] >@@ -71,6 +70,10 @@ > [% INCLUDE 'select2.inc' %] > [% INCLUDE 'js-patron-format.inc' %] > [% INCLUDE 'js-date-format.inc' %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% Asset.js("js/modals/place_booking.js") | $raw %] > [% Asset.js("js/cancel_booking_modal.js") | $raw %] > <script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt >index ee6aba2dd9e..5dc2992d539 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt >@@ -86,6 +86,11 @@ > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'catalog-strings.inc' %] >+ [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'select2.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >index 75acf77a0b0..bd6106afc90 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt >@@ -212,6 +212,11 @@ > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'catalog-strings.inc' %] >+ [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'select2.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 46426962705..765b5cdf89e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1129,8 +1129,8 @@ > [% END %] > > [% MACRO jsinclude BLOCK %] >- [% INCLUDE 'catalog-strings.inc' %] > [% INCLUDE 'calendar.inc' %] >+ [% INCLUDE 'catalog-strings.inc' %] > [% INCLUDE 'select2.inc' %] > [% INCLUDE 'js-date-format.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >@@ -1558,6 +1558,10 @@ > [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %] > [% INCLUDE 'columns_settings.inc' %] > [% INCLUDE 'js-date-format.inc' %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% INCLUDE 'js-patron-format.inc' %] > [% INCLUDE 'js-biblio-format.inc' %] > [% Asset.js("js/browser.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt >index 8be92a60391..291658980ff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt >@@ -139,6 +139,11 @@ > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'catalog-strings.inc' %] >+ [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'select2.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt >index 95eceaea958..89cbc33e43c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt >@@ -100,6 +100,11 @@ > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'catalog-strings.inc' %] >+ [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'select2.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index 6ef020cecbd..415ca90db2a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -518,6 +518,10 @@ > [% INCLUDE 'catalog-strings.inc' %] > [% INCLUDE 'modals/checkout_renewals.inc' %] > [% INCLUDE 'js-date-format.inc' %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrAfter.js") | $raw %] >+ [% Asset.js("lib/dayjs/plugin/isSameOrBefore.js") | $raw %] >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrAfter)</script> >+ <script>dayjs.extend(window.dayjs_plugin_isSameOrBefore)</script> > [% INCLUDE 'js-patron-format.inc' %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'select2.inc' %] >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 e92fee372bc..866ae3e6999 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >@@ -760,46 +760,28 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > } > > // Add hints for days before the start range and after the end range >- let leadDays = 2; >- let trailDays = 3; >+ const leadDays = 2; >+ const trailDays = 3; > periodPicker.calendarContainer.addEventListener( > "mouseover", >- function (e) { >- const target = e.target; >- const startDate = periodPicker.selectedDates[0] >- ? dayjs(periodPicker.selectedDates[0]).startOf( >- "day" >- ) >- : null; >- >+ function (event) { >+ const target = event.target; > if (target.classList.contains("flatpickr-day")) { > const hoverDate = dayjs(target.dateObj).startOf( > "day" > ); >- let leadStart; >- let leadEnd; >- const trailStart = hoverDate >- .add(0, "day") >- .startOf("day"); >- const trailEnd = hoverDate >- .add(trailDays, "day") >- .startOf("day"); >- >- if (!startDate) { >- leadStart = hoverDate >- .subtract(leadDays, "day") >- .startOf("day"); >- leadEnd = hoverDate >- .subtract(0, "day") >- .startOf("day"); >- } else { >- leadStart = startDate >- .subtract(leadDays, "day") >- .startOf("day"); >- leadEnd = startDate >- .subtract(0, "day") >- .startOf("day"); >- } >+ const startDate = periodPicker.selectedDates[0] >+ ? dayjs(periodPicker.selectedDates[0]).startOf( >+ "day" >+ ) >+ : null; >+ >+ const leadStart = startDate >+ ? startDate.subtract(leadDays, "day") >+ : hoverDate.subtract(leadDays, "day"); >+ const leadEnd = startDate ? startDate : hoverDate; >+ const trailStart = hoverDate; >+ const trailEnd = hoverDate.add(trailDays, "day"); > > periodPicker.calendarContainer > .querySelectorAll(".flatpickr-day") >@@ -808,57 +790,32 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > dayElem.dateObj > ).startOf("day"); > >- if (elemDate.isSame(leadStart)) { >- dayElem.classList.add("leadRangeStart"); >- } else { >- dayElem.classList.remove( >- "leadRangeStart" >- ); >- } >- >- if ( >- elemDate >= leadStart && >- elemDate < leadEnd >- ) { >- dayElem.classList.add("leadRange"); >- } else { >- dayElem.classList.remove("leadRange"); >- } >- >- if (elemDate.isSame(leadEnd)) { >- dayElem.classList.add("leadRangeEnd"); >- } else { >- dayElem.classList.remove( >- "leadRangeEnd" >- ); >- } >- >- if (elemDate.isSame(trailStart)) { >- dayElem.classList.add( >- "trailRangeStart" >- ); >- } else { >- dayElem.classList.remove( >- "trailRangeStart" >- ); >- } >- >- if ( >- elemDate > trailStart && >- elemDate <= trailEnd >- ) { >- dayElem.classList.add("trailRange"); >- } else { >- dayElem.classList.remove("trailRange"); >- } >- >- if (elemDate.isSame(trailEnd)) { >- dayElem.classList.add("trailRangeEnd"); >- } else { >- dayElem.classList.remove( >- "trailRangeEnd" >- ); >- } >+ dayElem.classList.toggle( >+ "leadRangeStart", >+ elemDate.isSame(leadStart) >+ ); >+ dayElem.classList.toggle( >+ "leadRange", >+ elemDate.isSameOrAfter(leadStart) && >+ elemDate.isBefore(leadEnd) >+ ); >+ dayElem.classList.toggle( >+ "leadRangeEnd", >+ elemDate.isSame(leadEnd) >+ ); >+ dayElem.classList.toggle( >+ "trailRangeStart", >+ elemDate.isSame(trailStart) >+ ); >+ dayElem.classList.toggle( >+ "trailRange", >+ elemDate.isAfter(trailStart) && >+ elemDate.isSameOrBefore(trailEnd) >+ ); >+ dayElem.classList.toggle( >+ "trailRangeEnd", >+ elemDate.isSame(trailEnd) >+ ); > }); > } > } >-- >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