Studio feature request: Add and create New in Editor screen

Hi CUBA team,
In Edit screen, we have only one option to create a record i.e. create and go back to browser. How about adding another button in extended window screen option for save and create new. The option is something similar to the post here: https://www.cuba-platform.com/discuss/t/ok-override-button-behavior

This will be very useful I believe.

Hi Mortoza,

This example: https://github.com/cuba-labs/demo-64-templates shows how to create such screen and template in your project. It has one shortcoming: the browser does not show added records because by default Create and Edit actions do not refresh the datasource. So you should use setAfterCommitHandler() methods of these actions to add ds.refresh() invocation.

Hi Konstantin
should I use setAfterCommitHandler() in Browse or Edit controller? If this is updated in your template demo that might be very helpful to many users in the community

It’s about Create and Edit actions in the browser screen.

Ok, got it. I just tried your code in one of the posts but see an error mark as attached.

and here is the controller codes



    @Inject
    private Button createNewBtn;
    private boolean needRefreshBrowser;
    // indicates for the calling code that we saved some entities
    // and the browser's datasource should be refreshed
    public boolean isNeedRefreshBrowser() {
        return needRefreshBrowser;
    }

    @Override
    public void init(Map<String, Object> params) {
        vendorCategoryDs.addItemPropertyChangeListener(e -> createNewBtn.setEnabled(true));
    }

    public void createNew() {
        getDsContext().commit();
        showNotification("Saved: " + getItem().getInstanceName(), NotificationType.TRAY);
        setItem(metadata.create(VendorCategory.class));
        fieldGroup.requestFocus();
        needRefreshBrowser = true;
    }

error1