Serenity: Custom Delete Message for Grid Editor Dialog in Entity Dialog

Created on 4 Dec 2017  路  4Comments  路  Source: serenity-is/Serenity

image

How can I change the text for this message?

Most helpful comment

Or maybe:

protected getToolbarButtons(): Serenity.ToolButton[] {
    var buttons = super.getToolbarButtons();
    Q.first(buttons, x => x.cssClass == "delete-button").onClick = () => 
        Q.confirm('your text', () => {
                this.doDelete(() => {
                    this.dialogClose();
                });
            });
        }
    });

    return buttons;
}

All 4 comments

image

I believe this will only change the confirmation for languages other than English, at least I don't see English as a choice in the texts. Also, that will change the text for all entity dialogs. I want the message to be dialog-specific. For example, when I'm deleting an address then the confirmation should say, "Are you sure you wish to delete this address?"

Thank you!

I think you have two ways.
First, unbind click event from delete button and then bind your custom event:

constructor() {
    super();

    this.deleteButton.unbind('click');
    this.deleteButton.on('click', (e) => {
        Q.confirm('your text', () => {
            this.doDelete(() => {
                this.dialogClose();
            });
        });
    });
}

Or you can override getToolbarButtons(), remove the delete button and recreate it

protected getToolbarButtons(): Serenity.ToolButton[] {
    var buttons = super.getToolbarButtons();

    buttons.splice(Q.indexOf(buttons, x => x.cssClass == "delete-button"), 1);
    buttons.push({
        title: Q.text('Controls.EntityDialog.DeleteButton'),
        cssClass: 'delete-button',
        hotkey: 'alt+x',
        onClick: () => {
            Q.confirm('your text', () => {
                this.doDelete(() => {
                    this.dialogClose();
                });
            });
        }
    });

    return buttons;
}

Or maybe:

protected getToolbarButtons(): Serenity.ToolButton[] {
    var buttons = super.getToolbarButtons();
    Q.first(buttons, x => x.cssClass == "delete-button").onClick = () => 
        Q.confirm('your text', () => {
                this.doDelete(() => {
                    this.dialogClose();
                });
            });
        }
    });

    return buttons;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahsansolution picture ahsansolution  路  3Comments

dkontod picture dkontod  路  3Comments

dudeman972 picture dudeman972  路  3Comments

john20xdoe picture john20xdoe  路  3Comments

gfo2007 picture gfo2007  路  3Comments