Bug 29212: (follow-up) Restore "Clear date" text for "Suspend all holds"

This patch restores the "Clear date to suspend indefinitely" link
associated with the "Suspend all holds" date input field.

The patch also introduces a generic ".clear-flatpickr" click handler for
Flatpickr instances.

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Owen Leonard 2022-01-31 16:31:54 +00:00 committed by Fridolin Somers
parent 72af322d18
commit 830d5f9f30
3 changed files with 10 additions and 6 deletions

View file

@ -126,6 +126,14 @@
$(document).ready(function(){
$(".flatpickr").flatpickr();
$(".clear-flatpickr").on("click", function(e){
e.preventDefault();
var element = $(this).data("fp");
if( element ){
document.querySelector("#" + element )._flatpickr.clear();
}
});
});
</script>

View file

@ -175,6 +175,7 @@
[% IF AutoResumeSuspendedHolds %]
<label for="suspend_until"> until </label>
<input type="text" name="suspend_until" id="suspend_until" class="flatpickr futuredate" size="10" />
<p><a href="#" class="clear-flatpickr" data-fp="suspend_until">Clear date to suspend indefinitely</a></p>
[% END %]
</form>
</div>

View file

@ -886,7 +886,7 @@
<label for="suspend_untilDate">Suspend until:</label>
<input type="text" name="suspend_until" id="suspend_untilDate" size="10" />
[% INCLUDE 'date-format.inc' %]
<p><a href="#" id="suspend-modal-clear-date">Clear date to suspend indefinitely</a></p>
<p><a href="#" class="clear-flatpickr" data-fp="suspend_untilDate">Clear date to suspend indefinitely</a></p>
</div>
<div class="modal-footer">
<button class="btn btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Suspend</button>
@ -987,11 +987,6 @@
$("#suspendHoldModal").modal("show");
});
$("#suspend-modal-clear-date").on( "click", function(e) {
e.preventDefault();
suspend_until_date.clear();
});
$("#suspendHoldModal").on("hidden.bs.modal", function(){
$("#suspendHoldTitle").html("");
$("#suspendHoldReserveId").val("");