From c022d32ea4fcbbc4930c155188bcb4baab5bf2b1 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 10 Oct 2023 13:36:45 +0200 Subject: [PATCH] Bug 35000: Fix OPACMandatoryHoldDates feature in opac-reserve Somewhere (perhaps after bug 29012) this feature has been broken somehow. The fact that we have two inputs for the date and the active one is one level deeper, requires a few adjustments in the jquery selectors etc. (Note that two Required lines were visible too.) The corrected jquery constructs become a bit complexer now. Test plan: Enable AllowHoldDateInFuture + OPACAllowHoldDateInFuture. Set circ rule for book to test with allows item level holds. Set OPACMandatoryHoldDates to no hold dates. Place hold on a book in OPAC. Check that More options is collapsed. (If you force item level holds, it will open.) Set OPACMandatoryHoldDates to Hold start date. Refresh place hold page. More options is expanded now. Click Place hold. You should see an alert and focus goes to start date. Set OPACMandatoryHoldDates to Hold end date. Repeat place hold. Set OPACMandatoryHoldDates to Both hold dates. Fill one. Place hold. Bonus: Place hold on multiple biblios. Repeat former steps. Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- .../bootstrap/en/modules/opac-reserve.tt | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index bc497b17f0e..e2918332a3a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -293,6 +293,7 @@ [% INCLUDE 'date-format.inc' %] + [% END %] @@ -300,6 +301,7 @@ [% INCLUDE 'date-format.inc' %] + [% IF Koha.Preference('AllowHoldItemTypeSelection') %] @@ -519,16 +521,11 @@ $(".toggle-hold-options").show(); $(".hold-options").hide(); var OPACMandatoryHoldDates = "[% Koha.Preference('OPACMandatoryHoldDates') | html %]"; - var requiredDiv = "
" + _("Required") + "
"; - if( OPACMandatoryHoldDates ) { - if( OPACMandatoryHoldDates == "start" || OPACMandatoryHoldDates == "both" ) { - $(".holddatefrom").prop( 'required', true ); - $(".holddatefrom").parent().append(requiredDiv); - } - if( OPACMandatoryHoldDates == "end" || OPACMandatoryHoldDates == "both" ) { - $(".futuredate").prop( 'required', true ); - $(".futuredate").parent().append(requiredDiv); - } + if( OPACMandatoryHoldDates == "start" || OPACMandatoryHoldDates == "both" ) { + $(".holddatefrom").prop( 'required', true ).siblings(".required_label").addClass('required').show(); + } + if( OPACMandatoryHoldDates == "end" || OPACMandatoryHoldDates == "both" ) { + $(".futuredate").prop( 'required', true ).siblings(".required_label").addClass('required').show(); } $(".checkitem").parent().click(function(e){ @@ -564,7 +561,7 @@ [% FOREACH bibitemloo IN bibitemloop %] [% IF bibitemloo.force_hold %] - if( $("#to[% bibitemloo.biblionumber | html %]:hidden").length ) + if( $("#to[% bibitemloo.biblionumber | html %]").parent(":hidden").length ) $("#toggle-hold-options-[% bibitemloo.biblionumber | html %]").click(); $("#reqspecific_[% bibitemloo.biblionumber | html %]").click(); $("#copiesrow_[% bibitemloo.biblionumber | html %]").show(); @@ -676,14 +673,14 @@ if( $(".holddatefrom").prop('required') && $("#from"+ biblioNum).val() == '' ) { alert(MSG_EMPTY_START_DATE); badBib = biblioNum; - if( $("#from"+biblioNum+":hidden").length ) $("#toggle-hold-options-"+biblioNum).click(); - $("#from"+ biblioNum).focus(); + if( $("#from"+biblioNum).parent(":hidden").length ) $("#toggle-hold-options-"+biblioNum).trigger('click'); + $("#from"+biblioNum).siblings('.flatpickr_wrapper').find('.flatpickr-input').trigger('focus'); return false; } else if( $(".futuredate").prop('required') && $("#to"+ biblioNum).val() == '' ) { alert(MSG_EMPTY_END_DATE); badBib = biblioNum; - if( $("#to"+biblioNum+":hidden").length ) $("#toggle-hold-options-"+biblioNum).click(); - $("#to"+ biblioNum).focus(); + if( $("#to"+biblioNum).parent(":hidden").length ) $("#toggle-hold-options-"+biblioNum).trigger('click'); + $("#to"+biblioNum).siblings('.flatpickr_wrapper').find('.flatpickr-input').trigger('focus'); return false; } -- 2.41.0