readOnlyMode

It can set the whole Gebra Suite app or some controls depending upon the use case which is required, in a readonly mode. All Input fields, save- new- and delete toolbar buttons are disabled.

In Gebra Suite, we have certain types of users like system users those who build the system, users those who will use the system, and admins, they will manage the systems etc. Each user should have different access to the system. It means all access rights should only be given to admin users. Lets suppose we have an orders app and recorded orders. System users should only be allowed to fetch and check orders while on the other hand admins should also be allowed to edit orders and make changes to them. This is this app readOnlyMode function comes into play.

Example

This code sets the whole app to read only mode. All the input controls and even the toolbar button get disabled.

Parameters

readOnlyMode function can be used with or without options. Following are the optional parameters:

  1. readOnly - (bool, default = true) This indicates if the readOnly mode is enabled (true) or disabled (false). If it is set to true or without options, it disables the whole app. If set to false, the app starts to behave normally. Every control and each toolbar button is enabled.

  2. options - It is a JSON object which can be passed as an additional options.

    • exclude - It is an array of controlIds that should be excluded from the disable functionality of readOnlyMode function.

Example Usages

We can use this "readOnlyMode" function with or without options. Lets see both of them in action.

Without options

To disable each and every control and toolbar buttons use this function without any options like

app.readOnlyMode(); // This will set app in readOnly Mode.
app.readOnlyMode(true); // This will also set complete app in readOnly Mode.

In order to enable all the controls, set the readOnlyMode function with false value of readOnly parameter. It will enable back all the controls and the app will start behaving normally.

app.readOnlyMode(false); // sets back to normal Mode.

With options

Now if we don't want to use default functionality of disabling or enabling the whole app, we can use readOnlyMode options to enable or disable some of the controls. Lets say we want to disable 2 controls from an app then we have to pass the names of these controls in exclude option array like

app.readOnlyMode(true, {
  exclude: ["myFrstControl", "mySecondControl"],
});

Example in Action

Lets say we have address app and we want to disable all of it. It can be done in different ways. For a moment, lets stick to "appInitialized" event. Add this function as a custom code of "appInitialized" event and save the app. It will look like this

As we can see each control as well as app toolbar is also disabled.

Return Values

Function does not explicitly produce return value.

Last updated