Bug 22272: Calendar: When entering date ranges grey out dates in the past from the start date

In "Calendar" tool it's possible to pick dates before start
date as end date.

This patch sets end date calendars "minDate" as picked start day
to grey out past dates. Also reindents datepicker code for
better readability.

Test plan:
- Apply this patch
- Set start date from first calendar
- Set end date from second calendar
=> Dates before start date are greyed out

Signed-off-by: Nadine Pierre <nadine.pierre@inLibro.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Emmi 2019-07-10 09:25:43 +03:00 committed by Martin Renvoize
parent 5c2daf28a5
commit 06e28c3ac5
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -516,43 +516,44 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl
$(this).parent().find(".hint").toggle(); return false;
});
$("#dateofrange").datepicker({
beforeShow: function() {
var startdate = $("#jcalendar-container").datepicker("getDate");
if (startdate !== null) {
var sd = new Date(startdate);
var ed = new Date($(this).datepicker("getDate"));
if (ed < sd) {
$(this).datepicker("setDate", startdate);
$(this).datepicker("option", "defaultDate", startdate);
}
beforeShow: function() {
var startdate = $("#jcalendar-container").datepicker("getDate");
if (startdate !== null) {
var sd = new Date(startdate);
var ed = new Date($(this).datepicker("getDate"));
if (ed < sd) {
$(this).datepicker("setDate", startdate);
$(this).datepicker("option", "defaultDate", startdate);
}
}
}
}
});
$("#datecancelrange").datepicker();
$("#dateofrange").each(function () { this.value = "" });
$("#datecancelrange").each(function () { this.value = "" });
$("#jcalendar-container").datepicker({
beforeShowDay: function(thedate) {
var day = thedate.getDate();
var month = thedate.getMonth() + 1;
var year = thedate.getFullYear();
var dateString = year + '/' + month + '/' + day;
return dateStatusHandler(dateString);
beforeShowDay: function(thedate) {
var day = thedate.getDate();
var month = thedate.getMonth() + 1;
var year = thedate.getFullYear();
var dateString = year + '/' + month + '/' + day;
return dateStatusHandler(dateString);
},
onSelect: function(dateText, inst) {
dateChanged($(this).datepicker("getDate"));
var enddate = $("#dateofrange").datepicker("getDate");
$("#dateofrange").datepicker("option", "defaultDate", $(this).datepicker("getDate"));
if (enddate !== null) {
var ed = new Date(enddate);
var sd = new Date($(this).datepicker("getDate"));
if (ed < sd) {
$("#dateofrange").datepicker("setDate", $(this).datepicker("getDate"));
$("#dateofrange").datepicker("option", "defaultDate", enddate);
}
}
},
defaultDate: new Date("[% keydate | html %]")
onSelect: function(dateText, inst) {
dateChanged($(this).datepicker("getDate"));
var enddate = $("#dateofrange").datepicker("getDate");
$("#dateofrange").datepicker("option", "defaultDate", $(this).datepicker("getDate"));
$("#dateofrange").datepicker( "option", "minDate", $(this).datepicker("getDate")); //ensure end date can't be before start date
if (enddate !== null) {
var ed = new Date(enddate);
var sd = new Date($(this).datepicker("getDate"));
if (ed < sd) {
$("#dateofrange").datepicker("setDate", $(this).datepicker("getDate"));
$("#dateofrange").datepicker("option", "defaultDate", enddate);
}
}
},
defaultDate: new Date("[% keydate | html %]")
});
$(".hidePanel").on("click",function(){
if( $(this).hasClass("showHoliday") ){