Bugzilla – Attachment 176636 Details for
Bug 38149
Make ESLint config compatible with version 9 and have ESLint and Prettier installed by default
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38149: Adjust tidy of some vue and js files after prettier upgrade
Bug-38149-Adjust-tidy-of-some-vue-and-js-files-aft.patch (text/plain), 40.06 KB, created by
Jonathan Druart
on 2025-01-16 11:22:58 UTC
(
hide
)
Description:
Bug 38149: Adjust tidy of some vue and js files after prettier upgrade
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-01-16 11:22:58 UTC
Size:
40.06 KB
patch
obsolete
>From 5654ca57b1070dbb326bed935d1a7d0c4b2a56c0 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 16 Jan 2025 09:37:19 +0100 >Subject: [PATCH] Bug 38149: Adjust tidy of some vue and js files after > prettier upgrade > >Fix xt/js_tidy.t and xt/vue_tidy.t > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/js/modals/place_booking.js | 569 +++++++++--------- > .../ERM/EHoldingsEBSCOTitlePackagesList.vue | 36 +- > .../prog/js/vue/components/ERM/Main.vue | 14 +- > .../ERM/UsageStatisticsReportBuilder.vue | 4 +- > .../js/vue/components/Preservation/Main.vue | 4 +- > 5 files changed, 324 insertions(+), 303 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 7b85ac53dac..2ba615b50a0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js >@@ -421,179 +421,182 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > f => f.name === "dateDisable" > ); > if (disableExists.length === 0) { >- periodPicker.config.disable.push(function dateDisable( >- date >- ) { >- // set local copy of selectedDates >- let selectedDates = periodPicker.selectedDates; >- >- // set booked counter >- let booked = 0; >+ periodPicker.config.disable.push( >+ function dateDisable(date) { >+ // set local copy of selectedDates >+ let selectedDates = periodPicker.selectedDates; > >- // reset the unavailable items array >- let unavailable_items = []; >+ // set booked counter >+ let booked = 0; > >- // reset the biblio level bookings array >- let biblio_bookings = []; >+ // reset the unavailable items array >+ let unavailable_items = []; > >- // disable dates before selected date >- if ( >- !selectedDates[1] && >- selectedDates[0] && >- selectedDates[0] > date >- ) { >- return true; >- } >+ // reset the biblio level bookings array >+ let biblio_bookings = []; > >- // iterate existing bookings >- for (booking of bookings) { >- // Skip if we're editing this booking >+ // disable dates before selected date > if ( >- booking_id && >- booking_id == booking.booking_id >+ !selectedDates[1] && >+ selectedDates[0] && >+ selectedDates[0] > date > ) { >- continue; >+ return true; > } > >- let start_date = flatpickr.parseDate( >- booking.start_date >- ); >- let end_date = flatpickr.parseDate( >- booking.end_date >- ); >- >- // patron has selected a start date (end date checks) >- if (selectedDates[0]) { >- // new booking start date is between existing booking start and end dates >+ // iterate existing bookings >+ for (booking of bookings) { >+ // Skip if we're editing this booking > if ( >- selectedDates[0] >= start_date && >- selectedDates[0] <= end_date >+ booking_id && >+ booking_id == booking.booking_id > ) { >- if (booking.item_id) { >- if ( >- unavailable_items.indexOf( >- booking.item_id >- ) === -1 >- ) { >- unavailable_items.push( >- booking.item_id >- ); >- } >- } else { >- if ( >- biblio_bookings.indexOf( >- booking.booking_id >- ) === -1 >- ) { >- biblio_bookings.push( >- booking.booking_id >- ); >- } >- } >+ continue; > } > >- // new booking end date would be between existing booking start and end dates >- else if ( >- date >= start_date && >- date <= end_date >- ) { >- if (booking.item_id) { >- if ( >- unavailable_items.indexOf( >- booking.item_id >- ) === -1 >- ) { >- unavailable_items.push( >- booking.item_id >- ); >- } >- } else { >- if ( >- biblio_bookings.indexOf( >- booking.booking_id >- ) === -1 >- ) { >- biblio_bookings.push( >- booking.booking_id >- ); >+ let start_date = flatpickr.parseDate( >+ booking.start_date >+ ); >+ let end_date = flatpickr.parseDate( >+ booking.end_date >+ ); >+ >+ // patron has selected a start date (end date checks) >+ if (selectedDates[0]) { >+ // new booking start date is between existing booking start and end dates >+ if ( >+ selectedDates[0] >= start_date && >+ selectedDates[0] <= end_date >+ ) { >+ if (booking.item_id) { >+ if ( >+ unavailable_items.indexOf( >+ booking.item_id >+ ) === -1 >+ ) { >+ unavailable_items.push( >+ booking.item_id >+ ); >+ } >+ } else { >+ if ( >+ biblio_bookings.indexOf( >+ booking.booking_id >+ ) === -1 >+ ) { >+ biblio_bookings.push( >+ booking.booking_id >+ ); >+ } > } > } >- } > >- // new booking would span existing booking >- else if ( >- selectedDates[0] <= start_date && >- date >= end_date >- ) { >- if (booking.item_id) { >- if ( >- unavailable_items.indexOf( >- booking.item_id >- ) === -1 >- ) { >- unavailable_items.push( >- booking.item_id >- ); >+ // new booking end date would be between existing booking start and end dates >+ else if ( >+ date >= start_date && >+ date <= end_date >+ ) { >+ if (booking.item_id) { >+ if ( >+ unavailable_items.indexOf( >+ booking.item_id >+ ) === -1 >+ ) { >+ unavailable_items.push( >+ booking.item_id >+ ); >+ } >+ } else { >+ if ( >+ biblio_bookings.indexOf( >+ booking.booking_id >+ ) === -1 >+ ) { >+ biblio_bookings.push( >+ booking.booking_id >+ ); >+ } > } >- } else { >- if ( >- biblio_bookings.indexOf( >- booking.booking_id >- ) === -1 >- ) { >- biblio_bookings.push( >- booking.booking_id >- ); >+ } >+ >+ // new booking would span existing booking >+ else if ( >+ selectedDates[0] <= start_date && >+ date >= end_date >+ ) { >+ if (booking.item_id) { >+ if ( >+ unavailable_items.indexOf( >+ booking.item_id >+ ) === -1 >+ ) { >+ unavailable_items.push( >+ booking.item_id >+ ); >+ } >+ } else { >+ if ( >+ biblio_bookings.indexOf( >+ booking.booking_id >+ ) === -1 >+ ) { >+ biblio_bookings.push( >+ booking.booking_id >+ ); >+ } > } > } >- } > >- // new booking would not conflict >- else { >- continue; >- } >+ // new booking would not conflict >+ else { >+ continue; >+ } > >- // check that there are available items >- // available = all bookable items - booked items - booked biblios >- let total_available = >- bookable_items.length - >- unavailable_items.length - >- biblio_bookings.length; >- if (total_available === 0) { >- return true; >+ // check that there are available items >+ // available = all bookable items - booked items - booked biblios >+ let total_available = >+ bookable_items.length - >+ unavailable_items.length - >+ biblio_bookings.length; >+ if (total_available === 0) { >+ return true; >+ } > } >- } > >- // patron has not yet selected a start date (start date checks) >- else if (date <= end_date && date >= start_date) { >- // same item, disable date >- if ( >- booking.item_id && >- booking.item_id == booking_item_id >+ // patron has not yet selected a start date (start date checks) >+ else if ( >+ date <= end_date && >+ date >= start_date > ) { >- return true; >- } >+ // same item, disable date >+ if ( >+ booking.item_id && >+ booking.item_id == booking_item_id >+ ) { >+ return true; >+ } > >- // count all clashes, both item and biblio level >- booked++; >- if (booked == bookable) { >- return true; >- } >+ // count all clashes, both item and biblio level >+ booked++; >+ if (booked == bookable) { >+ return true; >+ } > >- // FIXME: The above is not intelligent enough to spot >- // cases where an item must be used for a biblio level booking >- // due to all other items being booking within the biblio level >- // booking period... we end up with a clash >- // To reproduce: >- // * One bib with two bookable items. >- // * Add item level booking >- // * Add biblio level booking that extends one day beyond the item level booking >- // * Try to book the item without an item level booking from the day before the biblio level >- // booking is to be returned. Note this is a clash, the only item available for the biblio >- // level booking is the item you just booked out overlapping the end date. >+ // FIXME: The above is not intelligent enough to spot >+ // cases where an item must be used for a biblio level booking >+ // due to all other items being booking within the biblio level >+ // booking period... we end up with a clash >+ // To reproduce: >+ // * One bib with two bookable items. >+ // * Add item level booking >+ // * Add biblio level booking that extends one day beyond the item level booking >+ // * Try to book the item without an item level booking from the day before the biblio level >+ // booking is to be returned. Note this is a clash, the only item available for the biblio >+ // level booking is the item you just booked out overlapping the end date. >+ } > } > } >- }); >+ ); > } > > // Setup listener for itemtype select2 >@@ -713,121 +716,134 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > f => f.name === "periodChange" > ); > if (changeExists.length === 0) { >- periodPicker.config.onChange.push(function periodChange( >- selectedDates, >- dateStr, >- instance >- ) { >- // 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++) { >+ periodPicker.config.onChange.push( >+ function periodChange( >+ selectedDates, >+ dateStr, >+ instance >+ ) { >+ // 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(renewalLength) >+ nextDate.getDate() + parseInt(issueLength) > ); > boldDates.push(new Date(nextDate)); >- } > >- // Calculate the maximum date based on the selected start date >- let totalRenewalLength = >- parseInt(renewalsAllowed) * >- parseInt(renewalLength); >- let totalIssueLength = >- parseInt(issueLength) + >- parseInt(totalRenewalLength); >- >- const maxDate = new Date(startDate.getTime()); >- maxDate.setDate( >- maxDate.getDate() + totalIssueLength >- ); >+ // 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)); >+ } > >- // Update the maxDate option of the flatpickr instance >- instance.set("maxDate", maxDate); >- } >- // Range set, update hidden fields and set available items >- else if (selectedDates[0] && selectedDates[1]) { >- // set form fields from picker >- let picker_start = dayjs(selectedDates[0]); >- let picker_end = dayjs(selectedDates[1]).endOf( >- "day" >- ); >- $("#booking_start_date").val( >- picker_start.toISOString() >- ); >- $("#booking_end_date").val( >- picker_end.toISOString() >- ); >+ // Calculate the maximum date based on the selected start date >+ let totalRenewalLength = >+ parseInt(renewalsAllowed) * >+ parseInt(renewalLength); >+ let totalIssueLength = >+ parseInt(issueLength) + >+ parseInt(totalRenewalLength); >+ >+ const maxDate = new Date(startDate.getTime()); >+ maxDate.setDate( >+ maxDate.getDate() + totalIssueLength >+ ); > >- // set available items in select2 >- let booked_items = bookings.filter(function ( >- booking >- ) { >- let start_date = flatpickr.parseDate( >- booking.start_date >+ // Update the maxDate option of the flatpickr instance >+ instance.set("maxDate", maxDate); >+ } >+ // Range set, update hidden fields and set available items >+ else if (selectedDates[0] && selectedDates[1]) { >+ // set form fields from picker >+ let picker_start = dayjs(selectedDates[0]); >+ let picker_end = dayjs(selectedDates[1]).endOf( >+ "day" > ); >- let end_date = flatpickr.parseDate( >- booking.end_date >+ $("#booking_start_date").val( >+ picker_start.toISOString() > ); >- // This booking ends before the start of the new booking >- if (end_date <= selectedDates[0]) { >- return false; >- } >- // This booking starts after then end of the new booking >- if (start_date >= selectedDates[1]) { >- return false; >- } >- // This booking overlaps >- return true; >- }); >- $("#booking_item_id > option").each(function () { >- let option = $(this); >- if ( >- booking_item_id && >- booking_item_id == option.val() >- ) { >- option.prop("disabled", false); >- } else if ( >- booked_items.some(function (booked_item) { >- return ( >- option.val() == booked_item.item_id >+ $("#booking_end_date").val( >+ picker_end.toISOString() >+ ); >+ >+ // set available items in select2 >+ let booked_items = bookings.filter( >+ function (booking) { >+ let start_date = flatpickr.parseDate( >+ booking.start_date > ); >- }) >- ) { >- option.attr("data-available", false); >- option.prop("disabled", true); >- } else { >- option.attr("data-available", true); >- if (option.data("pickup")) { >- option.prop("disabled", false); >+ let end_date = flatpickr.parseDate( >+ booking.end_date >+ ); >+ // This booking ends before the start of the new booking >+ if (end_date <= selectedDates[0]) { >+ return false; >+ } >+ // This booking starts after then end of the new booking >+ if (start_date >= selectedDates[1]) { >+ return false; >+ } >+ // This booking overlaps >+ return true; > } >- } >- }); >- $("#booking_item_id").trigger("change.select2"); >- } >- // Range not set, reset field options and flatPickr state >- else { >- boldDates = []; >- instance.set("maxDate", null); >- $("#booking_item_id > option").each(function () { >- let option = $(this); >- if (option.data("pickup")) { >- option.prop("disabled", false); >- } >- }); >- $("#booking_item_id").trigger("change.select2"); >+ ); >+ $("#booking_item_id > option").each( >+ function () { >+ let option = $(this); >+ if ( >+ booking_item_id && >+ booking_item_id == option.val() >+ ) { >+ option.prop("disabled", false); >+ } else if ( >+ booked_items.some( >+ function (booked_item) { >+ return ( >+ option.val() == >+ booked_item.item_id >+ ); >+ } >+ ) >+ ) { >+ option.attr( >+ "data-available", >+ false >+ ); >+ option.prop("disabled", true); >+ } else { >+ option.attr("data-available", true); >+ if (option.data("pickup")) { >+ option.prop("disabled", false); >+ } >+ } >+ } >+ ); >+ $("#booking_item_id").trigger("change.select2"); >+ } >+ // Range not set, reset field options and flatPickr state >+ else { >+ boldDates = []; >+ instance.set("maxDate", null); >+ $("#booking_item_id > option").each( >+ function () { >+ let option = $(this); >+ if (option.data("pickup")) { >+ option.prop("disabled", false); >+ } >+ } >+ ); >+ $("#booking_item_id").trigger("change.select2"); >+ } > } >- }); >+ ); > } > > // Create a bookings store keyed on date >@@ -863,36 +879,33 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { > f => f.name === "dayCreate" > ); > if (dayCreateExists.length === 0) { >- periodPicker.config.onDayCreate.push(function dayCreate( >- dObj, >- dStr, >- instance, >- dayElem >- ) { >- const currentDate = dayElem.dateObj; >- const dateString = currentDate >- .toISOString() >- .split("T")[0]; >- >- const isBold = boldDates.some( >- boldDate => >- boldDate.getTime() === currentDate.getTime() >- ); >- if (isBold) { >- dayElem.classList.add("title"); >- } >+ periodPicker.config.onDayCreate.push( >+ function dayCreate(dObj, dStr, instance, dayElem) { >+ const currentDate = dayElem.dateObj; >+ const dateString = currentDate >+ .toISOString() >+ .split("T")[0]; >+ >+ 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[dateString].forEach(item => { >- const dot = document.createElement("span"); >- dot.className = "event item_" + item; >- dots.appendChild(dot); >- }); >+ if (bookingsByDate[dateString]) { >+ const dots = document.createElement("span"); >+ dots.className = "event-dots"; >+ dayElem.appendChild(dots); >+ bookingsByDate[dateString].forEach(item => { >+ const dot = document.createElement("span"); >+ dot.className = "event item_" + item; >+ dots.appendChild(dot); >+ }); >+ } > } >- }); >+ ); > } > > // Add hints for days before the start range and after the end range >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue >index 752a5286103..22329daec46 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlePackagesList.vue >@@ -160,23 +160,25 @@ export default { > ) > }, > initComplete: function () { >- $.fn.dataTable.ext.search.push(function apply_filter( >- settings, >- data, >- dataIndex, >- row >- ) { >- return ( >- row.package.name.match( >- new RegExp(filters.package_name, "i") >- ) && >- (filters.selection_type == 0 || >- (filters.selection_type == 1 && >- row.is_selected) || >- (filters.selection_type == 2 && >- !row.is_selected)) >- ) >- }) >+ $.fn.dataTable.ext.search.push( >+ function apply_filter( >+ settings, >+ data, >+ dataIndex, >+ row >+ ) { >+ return ( >+ row.package.name.match( >+ new RegExp(filters.package_name, "i") >+ ) && >+ (filters.selection_type == 0 || >+ (filters.selection_type == 1 && >+ row.is_selected) || >+ (filters.selection_type == 2 && >+ !row.is_selected)) >+ ) >+ } >+ ) > }, > }, > }) >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >index 3eaf6dd4891..7d0470c0fc9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >@@ -102,11 +102,11 @@ export default { > av_item_reports_metrics: "ERM_ITEM_REPORTS_METRICS", > } > >- let av_cat_array = Object.keys(authorised_values).map(function ( >- av_cat >- ) { >- return '"' + authorised_values[av_cat] + '"' >- }) >+ let av_cat_array = Object.keys(authorised_values).map( >+ function (av_cat) { >+ return '"' + authorised_values[av_cat] + '"' >+ } >+ ) > > promises.push( > av_client.values >@@ -184,7 +184,9 @@ form .v-select { > } > > .v-select, >-input:not([type="submit"]):not([type="search"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]), >+input:not([type="submit"]):not([type="search"]):not([type="button"]):not( >+ [type="checkbox"] >+ ):not([type="radio"]), > textarea { > border-color: rgba(60, 60, 60, 0.26); > border-width: 1px; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue >index 348ab40c838..622a0b74a50 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue >@@ -1041,7 +1041,9 @@ h2 { > width: 100%; > text-align: left; > } >-input:not([type="submit"]):not([type="search"]):not([type="button"]):not([type="checkbox"]) { >+input:not([type="submit"]):not([type="search"]):not([type="button"]):not( >+ [type="checkbox"] >+ ) { > min-width: 5%; > } > .month_selectors { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue >index 008c1393a71..8b4d01cc7a6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue >@@ -120,7 +120,9 @@ form .v-select { > } > > .v-select, >-input:not([type="submit"]):not([type="search"]):not([type="button"]):not([type="checkbox"]), >+input:not([type="submit"]):not([type="search"]):not([type="button"]):not( >+ [type="checkbox"] >+ ), > textarea { > border-color: rgba(60, 60, 60, 0.26); > border-width: 1px; >-- >2.34.1
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 38149
:
172682
|
172683
|
173010
|
173011
|
173012
|
174426
|
174427
|
174428
|
174852
|
174853
|
174854
|
175424
|
175425
|
175426
|
176193
|
176194
|
176587
|
176634
|
176635
| 176636