Corrected non working hour display in calendar table view.

This commit is contained in:
Alex Tselegidis 2020-05-04 13:20:16 +02:00
parent f47ceae466
commit 397ba1dfcf

View file

@ -759,15 +759,15 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
function createNonWorkingHours($calendar, workingPlan) { function createNonWorkingHours($calendar, workingPlan) {
var view = $calendar.fullCalendar('getView'); var view = $calendar.fullCalendar('getView');
var start = view.start.toDate(); var start = view.start.clone();
var end = view.end.toDate(); var end = view.end.clone();
var selDayName = start.toString('dddd').toLowerCase(); var selDayName = start.toDate().toString('dddd').toLowerCase();
if (workingPlan[selDayName] == null) { if (workingPlan[selDayName] == null) {
var nonWorkingDay = { var nonWorkingDay = {
title: EALang.not_working, title: EALang.not_working,
start: start.clone(), start: start,
end: end.clone(), end: end,
allDay: false, allDay: false,
color: '#BEBEBE', color: '#BEBEBE',
editable: false, editable: false,
@ -779,7 +779,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
return; return;
} }
var workDateStart = moment(start.toString('yyyy-MM-dd') + ' ' + workingPlan[selDayName].start); var workDateStart = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + workingPlan[selDayName].start);
if (start < workDateStart) { if (start < workDateStart) {
unavailablePeriod = { unavailablePeriod = {
@ -795,7 +795,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
} }
// Add unavailable period after work ends. // Add unavailable period after work ends.
var workDateEnd = moment(start.toString('yyyy-MM-dd') + ' ' + workingPlan[selDayName].end); var workDateEnd = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + workingPlan[selDayName].end);
if (end > workDateEnd) { if (end > workDateEnd) {
var unavailablePeriod = { var unavailablePeriod = {
@ -815,8 +815,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var breakEnd; var breakEnd;
workingPlan[selDayName].breaks.forEach(function (currentBreak, index) { workingPlan[selDayName].breaks.forEach(function (currentBreak, index) {
breakStart = moment(start.toString('yyyy-MM-dd') + ' ' + currentBreak.start); breakStart = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + currentBreak.start);
breakEnd = moment(start.toString('yyyy-MM-dd') + ' ' + currentBreak.end); breakEnd = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + currentBreak.end);
var unavailablePeriod = { var unavailablePeriod = {
title: EALang.break, title: EALang.break,