Hello!
I am trying to perform the assignment of Parent Events into the Scheduler Pro but I am having some issues when trying to move the Parent Event after scheduling it.
Parent Events that were already scheduled can be moved properly.
This is what I am using to perform this scheduling action inside the "onTaskDrop"
// Remove Task from Grid
me.grid.store.remove(task);
// Schedule Parent Event First
this.schedule.scheduleEvent({
resourceRecord : context.resource,
eventRecord : task,
startDate : startDate,
element: context.element
});
const children = [...task.children]; // Clone children, just in case.
// When parentEvent is scheduled, the order or the children will be defined based on "eventSequence"
children.sort((a, b) => {
if(!a.eventSequence || !b.eventSequence) {
return 0;
}
return a.eventSequence - b.eventSequence;
})
let previousChildDuration = 0;
// Schedule each children, passing the correct date offset for each child.
for(const child of children) {
const dateWithMinutesOffset = startDate.getTime() + previousChildDuration * 60000;
const adjustedDate = new Date(dateWithMinutesOffset);
this.schedule.scheduleEvent({
resourceRecord : context.resource,
eventRecord : child,
startDate : adjustedDate
});
previousChildDuration += child.duration;
}
context.finalize();
I did performed some debugging, and I see that the "context.valid" is false for the Event that I am trying to move.
Here is what I found so far to be the reason for "context.valid" to be false:
The "draggedEvent" that is stored inside "eventsToCheck" is getting its "startDate" reverted to its original Date after this line is processed:
await Promise.all([toScheduler.project !== fromScheduler.project ? toScheduler.project.commitAsync() : null, fromScheduler.project.commitAsync()]);
This will cause the date comparison to assign "false" to the "updated" property, which will later on be used to define "context.valid" to false.
I am trying to debug further and discover the reason why after the commitAsync promise the startDate of draggedEvent is reverting to its original startDate, but no luck on this yet.
Would the way I am trying to perform this Parent Events scheduling missing something that could be causing this issue?
Thank you!