Filter application properties

Hi,

Is it possible to extend the Application Properties screen and filter certain properties ? For instance, I would like to show the user a screen only with email server properties.

Thanks !

Alejandro

It is possible to block some users from seeing an entity’s some fields. It can be done only through configuration. No code change is needed.

Here is a belief of how to do it for reference.

Create a role and choose the entity and attributes you want to block.
Assign the user you want to block the role created.
image

In the screen above, I created a role “Read-Only” and wanted to restrict some of attributes of the entity “sec$User” from accessing. Actually, you can choose any entity and any attributes listing in the page.

1 Like

Peter,

I was referring to the system’s Application Properties screen.

image

Hi, @arapoport!

For application properties in the platform, a custom datasource AppPropertiesDatasource is used. To extend the Application Propeties screen you need to perform several steps:

  1. Extend AppPropertiesDatasource and override loadAppPropertyEntities method. For example, we show the user a screen with only email server properties:
public class AppPropertiesTestDatasource extends AppPropertiesDatasource {
    @Override
    public List<AppPropertyEntity> loadAppPropertyEntities() {
        return super.loadAppPropertyEntities()
                .stream()
                .filter(appPropertyEntity -> appPropertyEntity.getName().startsWith("cuba.email."))
                .collect(Collectors.toList());
    }
}
  1. Extend AppPropertiesBrowse.
  2. Extend XML descriptor appproperties-browse.xml. And override the paramsDs datasource using new datasourceClass AppPropertiesTestDatasource:
    <dsContext>
        <hierarchicalDatasource id="paramsDs"
                                class="com.haulmont.cuba.core.config.AppPropertyEntity"
                                view="_local"
                                hierarchyProperty="parent"
                                allowCommit="false"
                                datasourceClass="com.company.sample.web.screens.AppPropertiesTestDatasource">
        </hierarchicalDatasource>
    </dsContext>
  1. Override appProperties screen in web-screens.xml
    <screen id="appProperties"
            template="com/company/sample/web/screens/app-properties-browser-test.xml"
            route="app-properties"/>

I have created a test project (319.5 KB).

Regards,
Gleb

4 Likes

Gleb,

That was exactly was I looking for, thanks !!

Alejandro