Hi team,
I am having the following problem with dependency lag in combination with calendars in SchedulerPro. Let's look at an example:
Let's assume we have event A and event B, both with a duration of 2, and there is a dependency between them from the end of A to the start of B. Also, this dependency has a lag of 1 (unit is hours here).
Now, we also use a calendar to specify the working times of the events. For this calendar, we have a non-working time interval that is exactly the time span that is currently the gap between A and B. Thus, B needs to be rescheduled to start one hour later to satisfy the lag definition. The events will now look like this:
Here is the thing: When the interval was added during the initial load, this rescheduling happens perfectly, and the events end up in the correct state. BUT: When we modify the calendar later on, no rescheduling happens, A and B just reside in the same position as they were in 1.
To update the calendar, I am using the addIntervals
method. Below is the code for this example, which is adapted from one of the SchedulerPro examples, you can plug it into the examples (added comments to test the cases).
This bug actually leads to incorrectly scheduled events for us, so I am looking forward to your response. Thanks.
import { SchedulerPro } from '../../build/schedulerpro.module.js';
import shared from '../_shared/shared.module.js';
// region Data
const resources = [{ id: 'r1', name: 'Mike' }];
const events = [
{
id: 1,
resourceId: 'r1',
startDate: new Date(2017, 0, 1, 10),
endDate: new Date(2017, 0, 1, 12),
name: 'A',
iconCls: 'b-fa b-fa-mouse-pointer',
calendar: 'start',
},
{
id: 2,
resourceId: 'r1',
startDate: new Date(2017, 0, 1, 13),
endDate: new Date(2017, 0, 1, 15),
name: 'B',
iconCls: 'b-fa b-fa-arrows-alt',
calendar: 'start',
},
];
const dependencies = [
{
id: 't',
from: 1,
to: 2,
lag: 60,
lagUnit: 'm',
},
];
const interval = {
isWorking: false,
startDate: new Date(2017, 0, 1, 12),
endDate: new Date(2017, 0, 1, 13),
};
const calendars = [
{
id: 'start',
// Case 1: When directly adding the interval, rescheduling works.
// Comment out to test case 2.
intervals: [
interval
],
unspecifiedTimeIsWorking: true,
},
];
// endregion
const scheduler = new SchedulerPro({
appendTo: 'container',
resources,
events,
dependencies,
calendars,
features: {
dependencies: true,
dependencyEdit: true,
},
startDate: new Date(2017, 0, 1, 6),
endDate: new Date(2017, 0, 1, 20),
viewPreset: 'hourAndDay',
rowHeight: 50,
barMargin: 5,
multiEventSelect: true,
columns: [{ text: 'Name', field: 'name', width: 130 }],
});
setTimeout(() => {
// Case 2: When adding the interval later, the rescheduling does not work.
// Comment out to test case 1.
scheduler.calendars[0].addIntervals([interval]);
console.log(scheduler.calendars[0].intervals);
}, 2000);