Conditional drags crashes scheduler
3 years ago.
I am creating conditional drag where if I drag a scheduled or unscheduled item to the calendar where the date is in the past. A confirmation box will appear if I click no the item should return to its original position, otherwise it would proceed as normal. When I click no item doesn't return to original position and it freezes in new location and is greyed out. Any help?
onEventMove: async (args) => {
args.async = true;
const groupSplit = args.newResource.split('-');
if (Number(args.e.data.group_id) !== Number(groupSplit[1]) ){
args.preventDefault();
DayPilot.Modal.alert('Error occurred while assigning the task. Please assign task to correct group.');
return;
}
const date = new Date(args.newStart) // date of item
const now = new Date().setHours(0, 0, 0, 0); // today's date
if (now > date) {
const modal = await DayPilot.Modal.confirm("Are you sure?");
if (!modal.canceled) {
args.loaded()
calendarApp.assignTaskDnD(args.e, args.newStart, args.newEnd, args.newResource, args);
}
// item doesn't return to original position. It freezes in new location and is grayed out.
args.preventDefault();
} else {
args.loaded();
calendarApp.assignTaskDnD(args.e, args.newStart, args.newEnd, args.newResource, args);
}
},
DayPilot