Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom delete confirmation dialog in Task Editor #2879

Open
pmiklashevych opened this issue May 14, 2021 · 1 comment
Open

Implement custom delete confirmation dialog in Task Editor #2879

pmiklashevych opened this issue May 14, 2021 · 1 comment
Labels

Comments

@pmiklashevych
Copy link

pmiklashevych commented May 14, 2021

Requested here: https://www.bryntum.com/forum/viewtopic.php?f=51&t=17474&p=86684#p86684

https://www.bryntum.com/docs/gantt/#Gantt/feature/TaskEdit#config-confirmDelete
We have an option to ON/OFF it. Need a way to configure it.

Think of adding async context to the beforeTaskDelete handler to be able to confirm and continue task removing.

Workaround for now:

const gantt = new Gantt({
    features : {
        taskEdit : {
            // Disable default confirmation
            confirmDelete : false
        }
    },

    listeners : {
        beforeTaskDelete({ editor }) {
            // Add custom confirmation dialog
            if (!editor.confirmed) {
                const autoClose = editor.autoClose;
                editor.autoClose = false;

                // Show dialog here
                MessageDialog.confirm({
                    title       : 'Sure to delete?',
                    message     : 'Press YES to delete!',
                    rootElement : gantt.features.taskEdit.rootElement
                }).then(result => {
                    editor.autoClose = autoClose;

                    if (result === MessageDialog.yesButton) {
                        editor.confirmed = true;
                        // `delete` is a private function, but that is how to get back to delete operation
                        gantt.features.taskEdit.delete();
                    }
                });

                return false;
            }

            delete editor.confirmed;
            return true;
        }
    },
@pmiklashevych
Copy link
Author

Ideally the confirmation should be shown in all cases: editor, context menu, etc. There is a solution to add confirmation on beforeRemove on TaskStore, but there is a bug: #2878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant