serenity-is / Serenity

Business Apps Made Simple with Asp.Net Core MVC / TypeScript
https://serenity.is
MIT License
2.57k stars 796 forks source link

Inconsistent use of text settings for ApplyChangesButton vs other Buttons #6746

Closed DGoertzen closed 1 year ago

DGoertzen commented 1 year ago

Before submitting the bug report, please read and check the following items

What happened?

When App_Data\texts\user.texts.invariant.json is configured to:

  "Controls.EntityDialog.ApplyChangesButton": "Save",
  "Controls.EntityDialog.SaveButton": "Save and Close"

the title of the SaveButton is set, but it is the hint of the ApplyChangesButton that gets set.

What did you expect to happen?

I expected that setting the same type of parameter for a button will have the same effect on all buttons.

How to reproduce?

This can be reproduced by setting App_Data\texts\user.texts.invariant.json to:

  "Controls.EntityDialog.ApplyChangesButton": "Save",
  "Controls.EntityDialog.SaveButton": "Save and Close"

This problem arises from the code in the lines: https://github.com/serenity-is/Serenity/blob/4dea5d46752abe74aca6dd84385072f6dbe7f586/src/Serenity.Scripts/corelib/src/ui/dialogs/entitydialog.ts#L904 and https://github.com/serenity-is/Serenity/blob/4dea5d46752abe74aca6dd84385072f6dbe7f586/src/Serenity.Scripts/corelib/src/ui/dialogs/entitydialog.ts#L919

I think it would be better to have the buttons behave in the same way, and add local string support for both the title and the hint for all buttons.

What Serenity Nuget Versions are you seeing the problem on? (separated by comma)

Serenity Scripts 6.7.0

Serene template version

6.7.0

Sergen version

6.7.0

volkanceylan commented 1 year ago

works as designed

DGoertzen commented 1 year ago

Thanks for the quick response @volkanceylan! Sorry for not realizing that was as intended.

Given your response, my solution to change the text of the "Apply Changes" button was to add the following to xxxDialog.ts:

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

        var button = buttons.find(x => x.cssClass == 'apply-changes-button');
        button.title = localText('Controls.EntityDialog.ApplyChangesButton');
        return buttons;
    }

In order to change the text for the "Apply Changes" button globally, my understanding is that I need to create a child class of EntityDialog that all my Dialog classes are children of, or implement the above function in all of my Dialog classes. If there is another better way within the framework, I'd appreciate if you'd let me know. Thanks!