From c14294d08ef4ef7710d63aef9365659a25a8b9ea Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 16 Jan 2024 12:18:48 +0000 Subject: [PATCH] Bug 35813: (follow-up) Correct dialog class and clean up whitespace This patch changes the class of the success message from "success" (which is a Bootstrap class) to "message" which is the class we use elsewhere in Koha for this kind of informational message. The patch adds the same dialog markup to labeledMARCdetail.tt. The patch also trims trailing whitespace from place_booking_modal.js --- .../en/modules/catalogue/labeledMARCdetail.tt | 2 +- .../prog/js/place_booking_modal.js | 76 +++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) 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 c2d891cc99..c675dea065 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt @@ -46,7 +46,7 @@ [% IF ( unknownbiblionumber ) %]
The record you requested does not exist ([% biblionumber | html %]).
[% ELSE %] - +
[% INCLUDE 'cat-toolbar.inc' %]

diff --git a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js index 166958bb6b..7dc962c222 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/place_booking_modal.js @@ -121,7 +121,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { dataType: 'json', type: 'GET' }); - + // Fetch list of existing bookings let bookingsFetch = $.ajax({ url: '/api/v1/bookings?biblio_id=' + biblionumber, @@ -135,7 +135,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { dataType: 'json', type: 'GET' }); - + // Update item select2 and period flatpickr $.when(itemsFetch, bookingsFetch, checkoutsFetch).then( function(itemsFetch,bookingsFetch, checkoutsFetch){ @@ -157,7 +157,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { }; bookings.unshift(booking); } - + // Item select2 $("#booking_item_id").select2({ dropdownParent: $(".modal-content", "#placeBookingModal"), @@ -166,13 +166,13 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { minimumResultsForSearch: 20, placeholder: __("Select item") }); - + // Update flatpickr mode periodPicker.set('mode', 'range'); - + // Total bookable items let bookable = 0; - + for (item of bookable_items) { bookable++; // Populate item select (NOTE: Do we still need this check for pre-existing select option here?) @@ -183,29 +183,29 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { $('#booking_item_id').append(newOption); } } - + // Set disable function for periodPicker let disableExists = periodPicker.config.disable.filter(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; - + // reset the unavailable items array let unavailable_items = []; - + // 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) { @@ -216,10 +216,10 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { 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) { @@ -232,7 +232,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { } } } - + // 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) { @@ -245,7 +245,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { } } } - + // new booking would span existing booking else if (selectedDates[0] <= start_date && date >= end_date) { if (booking.item_id) { @@ -258,12 +258,12 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { } } } - + // 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; @@ -271,26 +271,26 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { 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) { 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: + // 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 @@ -301,15 +301,15 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { } }); }; - + // Setup listener for item select2 $('#booking_item_id').on('select2:select', function(e) { booking_item_id = e.params.data.id ? e.params.data.id : null; - + // redraw pariodPicker taking selected item into account periodPicker.redraw(); }); - + // Set onChange for flatpickr let changeExists = periodPicker.config.onChange.filter(f => f.name ==='periodChange'); if(changeExists.length === 0) { @@ -321,7 +321,7 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { 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); @@ -360,18 +360,18 @@ $('#placeBookingModal').on('show.bs.modal', function(e) { } }); }; - + // Enable flatpickr now we have date function populated periodPicker.redraw(); $("#period_fields :input").prop('disabled', false); - + // Redraw select with new options and enable $('#booking_item_id').trigger('change'); $("#booking_item_id").prop("disabled", false); // Set the flag to indicate that data has been fetched dataFetched = true; - + // Set form values setFormValues(patron_id,booking_item_id,start_date,end_date,periodPicker); }, @@ -459,7 +459,7 @@ $("#placeBookingForm").on('submit', function(e) { "patron_id": $('#booking_patron_id').find(':selected').val() }) ); - + posting.done(function(data) { // Update bookings store for subsequent bookings bookings.push(data); @@ -485,17 +485,17 @@ $("#placeBookingForm").on('submit', function(e) { }); timeline.focus(data.booking_id); } - + // Update bookings counts $('.bookings_count').html(parseInt($('.bookings_count').html(), 10)+1); // Set feedback - $('#transient_result').replaceWith('
'+_("Booking successfully placed")+'
'); + $('#transient_result').replaceWith('
'+_("Booking successfully placed")+'
'); // Close modal $('#placeBookingModal').modal('hide'); }); - + posting.fail(function(data) { $('#booking_result').replaceWith('
'+_("Failure")+'
'); }); @@ -513,7 +513,7 @@ $("#placeBookingForm").on('submit', function(e) { "patron_id": $('#booking_patron_id').find(':selected').val() }) }); - + putting.done(function(data) { update_success = 1; @@ -544,12 +544,12 @@ $("#placeBookingForm").on('submit', function(e) { } // Set feedback - $('#transient_result').replaceWith('
'+_("Booking successfully updated")+'
'); + $('#transient_result').replaceWith('
'+_("Booking successfully updated")+'
'); // Close modal $('#placeBookingModal').modal('hide'); }); - + putting.fail(function(data) { $('#booking_result').replaceWith('
'+__("Failure")+'
'); }); -- 2.30.2