[INFO REQ] Use MessageDialog.confirm for Task Deletion confirmation

Our state of the art Gantt chart


Post Reply
User avatar
bdowza
Posts: 2
Joined: Mon Jun 29, 2020 8:56 pm

[INFO REQ] Use MessageDialog.confirm for Task Deletion confirmation

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:

Code: Select all

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>:

Code: Select all

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

User avatar
mats
Core Developer
Core Developer
Posts: 16180
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: [INFO REQ] Use MessageDialog.confirm for Task Deletion confirmation

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)

Code: Select all

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.

Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
bdowza
Posts: 2
Joined: Mon Jun 29, 2020 8:56 pm

Re: [INFO REQ] Use MessageDialog.confirm for Task Deletion confirmation

Post by bdowza »

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


Post Reply