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>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-01-16 09:37:19 +01:00 committed by Katrin Fischer
parent 3961a3fa55
commit 04aa82aa23
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
5 changed files with 332 additions and 311 deletions

View file

@ -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;
periodPicker.config.disable.push(
function dateDisable(date) {
// set local copy of selectedDates
let selectedDates = periodPicker.selectedDates;
// set booked counter
let booked = 0;
// set booked counter
let booked = 0;
// reset the unavailable items array
let unavailable_items = [];
// reset the unavailable items array
let unavailable_items = [];
// reset the biblio level bookings array
let biblio_bookings = [];
// reset the biblio level bookings array
let biblio_bookings = [];
// disable dates before selected date
if (
!selectedDates[1] &&
selectedDates[0] &&
selectedDates[0] > date
) {
return true;
}
// 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
);
}
}
}
// 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
);
}
}
}
// 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;
}
// 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;
}
}
let start_date = flatpickr.parseDate(
booking.start_date
);
let end_date = flatpickr.parseDate(
booking.end_date
);
// 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 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 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
);
}
}
}
// 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;
}
// 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
) {
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]);
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++) {
// 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));
// 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
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);
}
// 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
);
// 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()
);
// set available items in select2
let booked_items = bookings.filter(function (
booking
) {
let start_date = flatpickr.parseDate(
booking.start_date
// 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");
);
$("#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");
}
}
// 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];
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");
}
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

View file

@ -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))
)
}
)
},
},
})

View file

@ -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;

View file

@ -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 {

View file

@ -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;