Our state of the art Gantt chart


Post by bdowza »

Hi all!
I have a couple questions regarding doing a confirmation before deleting a task. I am currently partially achieving this via:

new Gantt({
  ...
  listeners: {
    beforeTaskDelete() {
      return window.confirm("Are you sure you want to delete this task?");
    },
  },
})

However, I'd prefer use the MessageDialog.confirm over window.confirm. The issue with this is that MessageDialog.confirm is not a blocking action so the action to delete the task is executed at the same time as the MessageDialog.confirm is rendered. Is there a built in confirmation dialog that is a blocking action, or any other suggestions on how I can achieve preventing deletion based on the action return from MessageDialog.confirm?

Additionally, is there a way to conditionally prevent the Delete action via the TaskContextMenu? Should that delete action also trigger beforeTaskDelete (doesn't appear to be at the moment)?

BTW, MessageDialog.confirm (gantt-2.1.4) has it's return type defined as void, where I believe it should be a Promise<boolean>:

export class MessageDialog extends Popup {
    constructor(config?: Partial<MessageDialogConfig>);
    static confirm(options: object): void;
}

Post by mats »

To intercept and show an async prompt, you'll need to return false and show your prompt, and then delete the record manually (+ hide the editor)

Additionally, is there a way to conditionally prevent the Delete action via the TaskContextMenu? Should that delete action also trigger beforeTaskDelete (doesn't appear to be at the moment)?

It doesn't now as you saw, I've opened this ticket to normalize this: https://github.com/bryntum/support/issues/1097

Docs return type is wrong, good spot - we'll fix that right away.


Post by bdowza »

Great! Thanks Mats. Will give the manual option a shot.


Post Reply