How to lock edit screen

Hi,
I want to lock edit screen to make it display as view screen only.
How can I do that?

Thank you.

Hi,

For this purpose, you can use the User Roles platform feature. Create a role and set deny for all operations with the entity except read. Assign this role to the users you need to lock your edit screen for, and they will see the View button instead of Edit.

You can also take a look at our tutorial about User Roles and Access Rights.

1

2

Hi,

When an entity has 2 status pending and approved, if it change to approved, I want that entity cannot be modified any more, and the editor screen become a view screen. I can do this by copy a editor screen, change extends from AbstractWindow, remove commit action, disable components,… I want to ask there is any way to do faster :slight_smile:

Thanks for your comment.

Hi,
The most straightforward way would be the following:

contract-edit.xml

 <fieldGroup id="fieldGroup"
                    datasource="contractDs">
            <column width="250px">
                <field property="name"/>
                <field property="status"/>
            </column>
        </fieldGroup>

ContractEdit.java

public class ContractEdit extends AbstractEditor<Contract> {
    @Inject
    private FieldGroup fieldGroup;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        Contract contract = (Contract) WindowParams.ITEM.getEntity(params);
        if (contract != null && contract.getStatus() == Status.APPROVED) {
            fieldGroup.setEditable(false);
        }
    }
}
1 Like