Hey Guys,
I couldn't find a way to prevent the default delete logic, the beforeEventDelete listener didn't seem to work, and I couldn't stop the task editor delete button from showing the default confirm popup if I returned false from beforeEventDelete.
In saying that, by overriding the onItem on the delete item in the context menu, and adding my own delete button to the bbar on the task editor, I have the functionality I need.
Deleting from the context menu works fine
items.deleteTask.onItem = () => {
this.ganttTaskEditService.deleteTask(taskRecord, taskRecord.stores[0], null);
};
The delete button on the task editor shows my custom pop-up, but the task doesn't delete, and if it does, the delete doesn't send a request to the server
deleteConfirmButton.on('click', () => {
this.deleteTask(task, gantt.taskStore, editor);
}, this);
And the code for deleteTask() is:
deleteTask(task: GanttTask, taskStore: Store, editor?: TaskEditor) {
let message = 'Are you sure you want to delete this task';
if (task.children?.length) {
message = `This task has ${task.children.length} children.<br />
${message} and it's children`;
}
this.alertService.confirm(
'Delete Task',
`${message}?`,
'Delete Task',
'danger'
).subscribe((confirm) => {
if (confirm) {
taskStore.remove(task);
editor?.close();
}
});
}
What am I doing wrong?
Thanks
Chris