Koha/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js
Jonathan Druart f91ed3d8bf Bug 14060: Remove readonly attributes on date inputs
In order to remove accessibility issues due to the readonly attributes
on date inputs, this patch will remove them and introduce a javascript
validation on them.

This patch is not perfect for some reason:
I didn't manage to force the user to select a valid date. One solution
would be to reopen the datepicker plugin until a valid date is inserted.
But it could be annoying for users (and for me: I did not manage to
implement this solution).
You will note that input is emptied if the date is not valid. This is a
quick and efficient solution to prevent submitting invalid date and make
Koha explodes. A proper solution would be to implement the check server
side send a friendly message to the user.

Test plan:
For all inputs, try an invalid and a valid date.
 1/ Debar a patron
 2/ On the checkout tables (circulation and moremember), add a renewal
due date (at the bottom of the tables)
 3/ On the checkout page, specify a due date
 4/ On the return page, specify a return date
 5/ On the invoice page (acquisition module), enter a shipment and
billing date
 6/ On the invoice search page (invoices.pl) use filters shipment and
billing dates
 7/ On the offline circ page, specify a due date
 8/ On the edit patron page (memberentry), add a debarment
 9/ On the reserve page (reserve/request.pl), use the date inputs to
suspend until a defined date
10/ Edit patrons in a batch (tools/modborrowers.pl) and use the
registration and expiry date inputs

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-09-08 12:04:19 +00:00

112 lines
3.3 KiB
JavaScript

$(document).ready(function() {
$("#CheckAllExports").on("click",function(){
$(".export:visible").prop("checked", true);
return false;
});
$("#UncheckAllExports").on("click",function(){
$(".export:visible").prop("checked", false);
return false;
});
$('#patronlists').tabs({
activate: function( event, ui ) {
$('#'+ui.newTab.context.id).click();
}
});
$("#borrower_messages .cancel").on("click",function(){
$("#add_message_form").hide();
$("#addmessage").show();
});
$("#addmessage").on("click",function(){
$(this).hide();
$("#add_message_form").show();
});
$("input.radio").on("click",function(){
radioCheckBox($(this));
});
$("#newduedate").datetimepicker({
onClose: function(dateText, inst) {
validate_date(dateText, inst);
},
minDate: 1, // require that renewal date is after today
hour: 23,
minute: 59
});
$("#duedatespec").datetimepicker({
onClose: function(dateText, inst) {
if ( validate_date(dateText, inst) ) {
$("#barcode").focus();
}
},
hour: 23,
minute: 59
});
$("#export_submit").on("click",function(){
var output_format = $("#output_format").val();
export_checkouts(output_format);
return false;
});
var checkout_settings = $(".checkout-settings");
var checkout_settings_icon = $(".checkout-settings-icon");
// If any checkboxes in the checkout settings are selected, show the settings by default
if ( $(".checkout-settings input:checked,#duedatespec[value!='']").length ) {
checkout_settings.show();
checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
} else {
checkout_settings.hide();
checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
}
$("#show-checkout-settings a").on("click",function(){
if( checkout_settings.is(":hidden")){
checkout_settings.show();
checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
} else {
$("#barcode").focus();
checkout_settings.hide();
checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
}
});
});
function export_checkouts(format) {
if ($("input:checkbox[name='biblionumbers']:checked").length < 1){
alert(MSG_EXPORT_SELECT_CHECKOUTS);
return;
}
$("input:checkbox[name='biblionumbers']").each( function(){
var input_item = $(this).siblings("input:checkbox");
if ( $(this).is(":checked") ) {
$(input_item).prop("checked", true);
} else {
$(input_item).prop("checked", false);
}
} );
if (format == 'iso2709_995') {
format = 'iso2709';
$("#dont_export_item").val(0);
} else if (format == 'iso2709') {
$("#dont_export_item").val(1);
}
document.getElementById("output_format").value = format;
document.issues.submit();
}
function validate1(date) {
var today = new Date();
if ( date < today ) {
return true;
} else {
return false;
}
}