Bug 41061: Remove unused calendar JS functions
Since the introduction of Maskito by bug 33703 we do no longer need to valid dates when the flatpickr widget is closed. This patch removes the following JS function from staff and OPAC: * is_valid_date * validate_date * get_dateformat_str Test plan: 0. Do not apply this patch and confirm that the date string received by those functions has already been correctly formatted 1. Apply the patch and git grep to make sure no occurrence exists in the code 2. Confirm that you are still able to select dates with flatpickr Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
6f6817d691
commit
6aa88ceb28
|
|
@ -155,7 +155,6 @@
|
|||
}
|
||||
},
|
||||
onClose: function( selectedDates, dateText, instance) {
|
||||
validate_date( dateText, instance );
|
||||
var thisInput = instance.input;
|
||||
if ( thisInput.hasAttribute('data-date_to') ) {
|
||||
var endPickerEl = document.querySelector("#"+thisInput.dataset.date_to);
|
||||
|
|
|
|||
|
|
@ -9,53 +9,6 @@ if (debug > 1) {
|
|||
);
|
||||
}
|
||||
|
||||
function is_valid_date(date) {
|
||||
// An empty string is considered as a valid date for convenient reasons.
|
||||
if (date === "") return 1;
|
||||
var dateformat = flatpickr_dateformat_string;
|
||||
if (dateformat == "us") {
|
||||
if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
|
||||
dateformat = "m/d/Y";
|
||||
} else if (dateformat == "metric") {
|
||||
if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
|
||||
dateformat = "d/m/Y";
|
||||
} else if (dateformat == "iso") {
|
||||
if (date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1) return 0;
|
||||
dateformat = "Y-m-d";
|
||||
} else if (dateformat == "dmydot") {
|
||||
if (date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1) return 0;
|
||||
dateformat = "d.m.Y";
|
||||
}
|
||||
try {
|
||||
flatpickr.parseDate(date, dateformat);
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function get_dateformat_str(dateformat) {
|
||||
var dateformat_str;
|
||||
if (dateformat == "us") {
|
||||
dateformat_str = "mm/dd/yyyy";
|
||||
} else if (dateformat == "metric") {
|
||||
dateformat_str = "dd/mm/yyyy";
|
||||
} else if (dateformat == "iso") {
|
||||
dateformat_str = "yyyy-mm-dd";
|
||||
} else if (dateformat == "dmydot") {
|
||||
dateformat_str = "dd.mm.yyyy";
|
||||
}
|
||||
return dateformat_str;
|
||||
}
|
||||
|
||||
function validate_date(dateText, inst) {
|
||||
if (!is_valid_date(dateText)) {
|
||||
var dateformat_str = get_dateformat_str(dateformat_pref);
|
||||
alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str));
|
||||
inst.clear();
|
||||
}
|
||||
}
|
||||
|
||||
function Date_from_syspref(dstring) {
|
||||
var dateX = dstring.split(/[-/.]/);
|
||||
if (debug > 1 && sentmsg < 1) {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ $(document).ready(function () {
|
|||
return $("#enrolmentperiod").val() === "";
|
||||
},
|
||||
enrollment_period: true,
|
||||
// is_valid_date ($(#"enrolementperioddate").val());
|
||||
},
|
||||
dateofbirthrequired: {
|
||||
digits: true,
|
||||
|
|
|
|||
|
|
@ -42,20 +42,6 @@
|
|||
altinput_dateformat = 'yyyy/mm/dd';
|
||||
delimiter = "-";
|
||||
}
|
||||
|
||||
function get_dateformat_str(dateformat) {
|
||||
var dateformat_str;
|
||||
if (dateformat == 'us') {
|
||||
dateformat_str = 'mm/dd/yyyy';
|
||||
} else if (dateformat == 'metric') {
|
||||
dateformat_str = 'dd/mm/yyyy';
|
||||
} else if (dateformat == 'iso') {
|
||||
dateformat_str = 'yyyy-mm-dd';
|
||||
} else if (dateformat == 'dmydot') {
|
||||
dateformat_str = 'dd.mm.yyyy';
|
||||
}
|
||||
return dateformat_str;
|
||||
}
|
||||
</script>
|
||||
[% Asset.js("lib/flatpickr/flatpickr.min.js") | $raw %]
|
||||
[% Asset.js("lib/maskito/maskito.core.js") | $raw %]
|
||||
|
|
@ -117,7 +103,6 @@
|
|||
new Maskito(instance.altInput, options);
|
||||
},
|
||||
onClose: function (selectedDates, dateText, instance) {
|
||||
validate_date(dateText, instance);
|
||||
var thisInput = instance.input;
|
||||
if (thisInput.hasAttribute("data-start_for")) {
|
||||
var endPicker = document.querySelector("#" + thisInput.dataset.start_for)._flatpickr;
|
||||
|
|
@ -128,39 +113,6 @@
|
|||
|
||||
var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s).");
|
||||
|
||||
function is_valid_date(date) {
|
||||
// An empty string is considered as a valid date for convenient reasons.
|
||||
if (date === "") return 1;
|
||||
var dateformat = flatpickr_dateformat_string;
|
||||
switch (dateformat_pref) {
|
||||
case "us":
|
||||
flatpickr_dateformat_string = "m/d/Y";
|
||||
break;
|
||||
case "metric":
|
||||
flatpickr_dateformat_string = "d/m/Y";
|
||||
break;
|
||||
case "dmydot":
|
||||
flatpickr_dateformat_string = "d.m.Y";
|
||||
break;
|
||||
default:
|
||||
flatpickr_dateformat_string = "Y-m-d";
|
||||
}
|
||||
try {
|
||||
flatpickr.parseDate(date, dateformat);
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function validate_date(dateText, inst) {
|
||||
if (!is_valid_date(dateText)) {
|
||||
var dateformat_str = get_dateformat_str(dateformat_pref);
|
||||
alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str));
|
||||
inst.clear();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".flatpickr").each(function () {
|
||||
let options = {};
|
||||
|
|
|
|||
Loading…
Reference in New Issue